MCPcopy Create free account
hub / github.com/DataArcTech/ToG / run_llm

Function run_llm

CoT/utils.py:5–32  ·  view source on GitHub ↗
(prompt, temperature, max_tokens, opeani_api_keys, engine="gpt-3.5-turbo")

Source from the content-addressed store, hash-verified

3import json
4
5def run_llm(prompt, temperature, max_tokens, opeani_api_keys, engine="gpt-3.5-turbo"):
6 if "llama" not in engine.lower():
7 openai.api_key = "EMPTY"
8 openai.api_base = "http://localhost:8000/v1" # your local llama server port
9 engine = openai.Model.list()["data"][0]["id"]
10 else:
11 openai.api_key = opeani_api_keys
12
13 messages = [{"role":"system","content":"You are an AI assistant that helps people find information."}]
14 message_prompt = {"role":"user","content":prompt}
15 messages.append(message_prompt)
16 print("start openai")
17 while(f == 0):
18 try:
19 response = openai.ChatCompletion.create(
20 model=engine,
21 messages = messages,
22 temperature=temperature,
23 max_tokens=max_tokens,
24 frequency_penalty=0,
25 presence_penalty=0)
26 result = response["choices"][0]['message']['content']
27 f = 1
28 except:
29 print("openai error, retry")
30 time.sleep(2)
31 print("end openai")
32 return result
33
34def prepare_dataset(dataset_name):
35 if dataset_name == 'cwq':

Callers 1

cot_io.pyFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected