(prompt, temperature, max_tokens, opeani_api_keys, engine="gpt-3.5-turbo")
| 104 | |
| 105 | |
| 106 | def 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 | |
| 135 | def all_unknown_entity(entity_candidates): |
no outgoing calls
no test coverage detected