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 chatgpt.py #9

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
7 changes: 5 additions & 2 deletions llmriddles/llms/chatgpt.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
from functools import lru_cache

from openai import OpenAI
import os
_LLM_URL = os.environ.get('QUESTION_LLM_URL', None)
_LLM_MODEL = os.environ.get('QUESTION_LLM_MODEL', "gpt-3.5-turbo")

from .base import register_llm


@lru_cache()
def _get_openai_client(api_key):
return OpenAI(api_key=api_key)
return OpenAI(api_key=api_key, base_url=_LLM_URL)


def ask_chatgpt(message: str, api_key: str):
client = _get_openai_client(api_key)

response = client.chat.completions.create(
model="gpt-3.5-turbo",
model=_LLM_MODEL,
messages=[
{"role": "user", "content": message}
],
Expand Down