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

Function run_llm

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

Source from the content-addressed store, hash-verified

104
105
106def run_llm(prompt, temperature, max_tokens, opeani_api_keys, engine="gpt-3.5-turbo"):
107 if "llama" in engine.lower():
108 openai.api_key = "EMPTY"
109 openai.api_base = "http://localhost:8000/v1" # your local llama server port
110 engine = openai.Model.list()["data"][0]["id"]
111 else:
112 openai.api_key = opeani_api_keys
113
114 messages = [{"role":"system","content":"You are an AI assistant that helps people find information."}]
115 message_prompt = {"role":"user","content":prompt}
116 messages.append(message_prompt)
117 f = 0
118 while(f == 0):
119 try:
120 response = openai.ChatCompletion.create(
121 model=engine,
122 messages = messages,
123 temperature=temperature,
124 max_tokens=max_tokens,
125 frequency_penalty=0,
126 presence_penalty=0)
127 result = response["choices"][0]['message']['content']
128 f = 1
129 except:
130 print("openai error, retry")
131 time.sleep(2)
132 return result
133
134
135def all_unknown_entity(entity_candidates):

Callers 9

relation_search_pruneFunction · 0.70
entity_scoreFunction · 0.70
generate_answerFunction · 0.70
reasoningFunction · 0.70
relation_search_pruneFunction · 0.70
entity_scoreFunction · 0.70
generate_answerFunction · 0.70
reasoningFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected