Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update docs #377

Merged
merged 2 commits into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 15 additions & 12 deletions .env.exp
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
# Please copy this file to .env and fill blank you need
OPENAI_API_KEY=sk-xxx
OPENAI_API_MODEL=gpt-3.5-turbo-0613
OPENAI_API_RETRIEVE_MODEL=gpt-3.5-turbo-16k
OPENAI_API_ENDPOINT=https://api.openai.com/v1/chat/completions
# OPENAI_API_ORG_ID=org-xxx
# OPENAI_API_PROXY=socks5://127.0.0.1:7890
# NOTE:If you want to share your bot to **everyone**
# GLOBAL_OAI_KEY=sk-xxx
# GLOBAL_OAI_MODEL=gpt-3.5-turbo-0613
# GLOBAL_OAI_ENDPOINT=https://api.openai.com/v1/

AMQP_DSN=amqp://admin:8a8a8a@localhost:5672/
REDIS_DSN=redis://localhost:6379/0
MONGODB_DSN=mongodb://admin:8a8a8a@localhost:27017/?authSource=admin
# SENTRY_DSN=xxxx

SERVICE_PROVIDER=public
# NOTE:NOT MUST,OR USE local file database # # #
# REDIS_DSN=redis://localhost:6379/0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment here is unclear and might confuse users. Consider rephrasing for better clarity.

- # NOTE:NOT MUST,OR USE local file database # # #
+ # NOTE: Optional - Use a local file database if preferred

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
# NOTE:NOT MUST,OR USE local file database # # #
# NOTE: Optional - Use a local file database if preferred

# MONGODB_DSN=mongodb://admin:8a8a8a@localhost:27017/?authSource=admin
# NOT MUST # # #

# NOTE:When you have too much message, you can set it.
# STOP_REPLY=anything

# NOTE:sentry logger
# SENTRY_DSN=xxxx

# TELEGRAM_BOT_TOKEN=xxx
# TELEGRAM_BOT_PROXY_ADDRESS=socks5://127.0.0.1:7890
Expand All @@ -27,4 +30,4 @@ SERVICE_PROVIDER=public
# SLACK_SIGNING_SECRET=xxxxxxxxxxxxx
# SLACK_BOT_PROXY_ADDRESS=http://

# LLMBOT_LOG_OUTPUT=DEBUG
# PLUGIN_*
Binary file added .github/sponsor_ohmygpt.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
workflow_dispatch:
push:
tags:
- pypi*
- pypi-*

permissions:
contents: read
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,10 @@ env - Environment variables of the function
Refer to the example plugins in the `plugins` directory and
the [🧀 Plugin Development Document](https://llmkira.github.io/Docs/dev/basic) for plugin development documentation.

## 🧀 Sponsor

[![sponsor](./.github/sponsor_ohmygpt.png)](https://www.ohmygpt.com)

## 📜 Notice

> This project, named OpenAiBot, signifying "Open Artificial Intelligence Robot", is not officially affiliated with
Expand Down
16 changes: 16 additions & 0 deletions app/components/credential.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import os
from urllib.parse import urlparse

import requests
from dotenv import load_dotenv
from loguru import logger
from pydantic import BaseModel


Expand Down Expand Up @@ -62,3 +65,16 @@ def is_valid_url(url):
# 其他情况
else:
return None


load_dotenv()

if os.getenv("GLOBAL_OAI_KEY") and os.getenv("GLOBAL_OAI_ENDPOINT"):
logger.warning("\n\n**Using GLOBAL credential**\n\n")
global_credential = Credential(
api_key=os.getenv("GLOBAL_OAI_KEY"),
api_endpoint=os.getenv("GLOBAL_OAI_ENDPOINT"),
api_model=os.getenv("GLOBAL_OAI_MODEL", "gpt-3.5-turbo"),
)
else:
global_credential = None
4 changes: 3 additions & 1 deletion app/receiver/receiver_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from loguru import logger
from telebot import formatting

from app.components.credential import Credential
from app.components.credential import Credential, global_credential
from app.components.user_manager import USER_MANAGER
from app.middleware.llm_task import OpenaiMiddleware
from llmkira.kv_manager.env import EnvManager
Expand Down Expand Up @@ -242,6 +242,8 @@ async def _flash(
try:
try:
credentials = await read_user_credential(user_id=task.receiver.uid)
if global_credential:
credentials = global_credential
assert credentials, "You need to /login first"
llm_result = await llm.request_openai(
remember=remember,
Expand Down
Loading