CodeGeeX4/repodemo/llm/api/codegeex4.py

23 lines
581 B
Python
Raw Normal View History

2024-07-05 01:33:53 +00:00
import json
from openai import OpenAI
import requests
import os
def codegeex4(messages_list, temperature=0.2, top_p=0.95):
openai_api_key = os.getenv("openai_api_key")
openai_api_base = os.getenv("openai_api_base")
model_name = os.getenv("model_name")
2024-07-05 01:33:53 +00:00
client = OpenAI(
api_key=openai_api_key,
base_url=openai_api_base,
)
2024-07-09 03:37:30 +00:00
chat_response = client.chat.completions.create(
model=model_name,
messages=messages_list,
temperature=temperature,
top_p=top_p
)
return chat_response.choices[0].message.content