Skip to content

Commit

Permalink
refactor: (#350)
Browse files Browse the repository at this point in the history
  • Loading branch information
dongjing007 authored Oct 25, 2023
1 parent 8b3e9e8 commit 414b77f
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions xiaogpt/bot/langchain_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,30 @@ def __init__(
self,
openai_key: str,
serpapi_api_key: str,
proxy: str | None = None,
api_base: str | None = None,
) -> None:
# Set environment indicators
os.environ["OPENAI_API_KEY"] = openai_key
os.environ["SERPAPI_API_KEY"] = serpapi_api_key
# todo,Plan to implement within langchain
if api_base:
os.environ["OPENAI_API_BASE"] = api_base
if proxy:
os.environ["OPENAI_PROXY"] = proxy
# Todo,Plan to implement within langchain
self.history = []

@classmethod
def from_config(cls, config):
return cls(openai_key=config.openai_key, serpapi_api_key=config.serpapi_api_key)
return cls(
openai_key=config.openai_key,
serpapi_api_key=config.serpapi_api_key,
proxy=config.proxy,
api_base=config.api_base,
)

async def ask(self, query, **options):
# todo,Currently only supports stream
# Todo,Currently only supports stream
raise Exception(
"The bot does not support it. Please use 'ask_stream,add: --stream'"
)
Expand Down

0 comments on commit 414b77f

Please sign in to comment.