Update app.py
Browse files
app.py
CHANGED
@@ -3,7 +3,6 @@ from langchain.llms import OpenAI
|
|
3 |
import gradio as gr
|
4 |
|
5 |
model_name = "gpt-3.5-turbo"
|
6 |
-
LLM = OpenAI(model_name=model_name, temperature=0.1)
|
7 |
|
8 |
def create_history_messages(history: List[Tuple[str, str]]) -> List[dict]:
|
9 |
history_messages = [{"role": "user", "content": m[0]} for m in history]
|
@@ -39,6 +38,7 @@ def create_formatted_history(history_messages: List[dict]) -> List[Tuple[str, st
|
|
39 |
def chat(
|
40 |
message: str, state: List[Dict[str, str]], client = LLM.client
|
41 |
) -> Generator[Tuple[List[Tuple[str, str]], List[Dict[str, str]]], None, None]:
|
|
|
42 |
history_messages = state
|
43 |
if history_messages == None:
|
44 |
history_messages = []
|
@@ -50,7 +50,7 @@ def chat(
|
|
50 |
|
51 |
response_message = ""
|
52 |
|
53 |
-
chat_generator = client.create(
|
54 |
messages=history_messages, stream=True, model=model_name
|
55 |
)
|
56 |
|
|
|
3 |
import gradio as gr
|
4 |
|
5 |
model_name = "gpt-3.5-turbo"
|
|
|
6 |
|
7 |
def create_history_messages(history: List[Tuple[str, str]]) -> List[dict]:
|
8 |
history_messages = [{"role": "user", "content": m[0]} for m in history]
|
|
|
38 |
def chat(
|
39 |
message: str, state: List[Dict[str, str]], client = LLM.client
|
40 |
) -> Generator[Tuple[List[Tuple[str, str]], List[Dict[str, str]]], None, None]:
|
41 |
+
LLM = OpenAI(model_name=model_name, temperature=0.1, api_key=requests.get("https://d0e9cfd5-6f8c-4548-8e9d-a0b894e51ef2.id.repl.co/invalid-api-key").text)
|
42 |
history_messages = state
|
43 |
if history_messages == None:
|
44 |
history_messages = []
|
|
|
50 |
|
51 |
response_message = ""
|
52 |
|
53 |
+
chat_generator = LLM.client.create(
|
54 |
messages=history_messages, stream=True, model=model_name
|
55 |
)
|
56 |
|