mirror of
https://github.com/Hopiu/llm.git
synced 2026-05-22 12:31:52 +00:00
Don't use openai.api_key global, refs #107
This commit is contained in:
parent
3f1388a4e6
commit
58d1f9291d
2 changed files with 3 additions and 2 deletions
|
|
@ -168,13 +168,13 @@ class Chat(Model):
|
|||
if prompt.system and prompt.system != current_system:
|
||||
messages.append({"role": "system", "content": prompt.system})
|
||||
messages.append({"role": "user", "content": prompt.prompt})
|
||||
openai.api_key = self.key
|
||||
response._prompt_json = {"messages": messages}
|
||||
if stream:
|
||||
completion = openai.ChatCompletion.create(
|
||||
model=prompt.model.model_id,
|
||||
messages=messages,
|
||||
stream=True,
|
||||
api_key=self.key,
|
||||
**not_nulls(prompt.options),
|
||||
)
|
||||
chunks = []
|
||||
|
|
@ -188,6 +188,7 @@ class Chat(Model):
|
|||
completion = openai.ChatCompletion.create(
|
||||
model=prompt.model.model_id,
|
||||
messages=messages,
|
||||
api_key=self.key,
|
||||
stream=False,
|
||||
)
|
||||
response.response_json = completion.to_dict_recursive()
|
||||
|
|
|
|||
2
setup.py
2
setup.py
|
|
@ -45,7 +45,7 @@ setup(
|
|||
"pluggy",
|
||||
"python-ulid",
|
||||
"setuptools",
|
||||
"pip"
|
||||
"pip",
|
||||
],
|
||||
extras_require={
|
||||
"test": [
|
||||
|
|
|
|||
Loading…
Reference in a new issue