Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
# coding=utf8
|
2 |
from gpt_index import SimpleDirectoryReader, GPTListIndex, GPTSimpleVectorIndex, LLMPredictor, PromptHelper
|
3 |
from langchain import OpenAI
|
|
|
4 |
import gradio as gr
|
5 |
import random
|
6 |
import time
|
@@ -148,15 +149,15 @@ def chatbot(input_text):
|
|
148 |
response = index.query(input_text)
|
149 |
return str(response.response)
|
150 |
|
151 |
-
def chat(
|
152 |
# We use the Chat Completion endpoint for chat like inputs
|
153 |
-
response =
|
154 |
# model used here is ChatGPT
|
155 |
# You can use all these models for this endpoint:
|
156 |
# gpt-4, gpt-4-0314, gpt-4-32k, gpt-4-32k-0314,
|
157 |
# gpt-3.5-turbo, gpt-3.5-turbo-0301
|
158 |
model="gpt-3.5-turbo",
|
159 |
-
messages=
|
160 |
# max_tokens generated by the AI model
|
161 |
# maximu value can be 4096 tokens for "gpt-3.5-turbo"
|
162 |
max_tokens = MaxToken,
|
|
|
1 |
# coding=utf8
|
2 |
from gpt_index import SimpleDirectoryReader, GPTListIndex, GPTSimpleVectorIndex, LLMPredictor, PromptHelper
|
3 |
from langchain import OpenAI
|
4 |
+
import openai
|
5 |
import gradio as gr
|
6 |
import random
|
7 |
import time
|
|
|
149 |
response = index.query(input_text)
|
150 |
return str(response.response)
|
151 |
|
152 |
+
def chat(input_text, MaxToken=50, outputs=3):
|
153 |
# We use the Chat Completion endpoint for chat like inputs
|
154 |
+
response = openai.ChatCompletion.create(
|
155 |
# model used here is ChatGPT
|
156 |
# You can use all these models for this endpoint:
|
157 |
# gpt-4, gpt-4-0314, gpt-4-32k, gpt-4-32k-0314,
|
158 |
# gpt-3.5-turbo, gpt-3.5-turbo-0301
|
159 |
model="gpt-3.5-turbo",
|
160 |
+
messages=input_text,
|
161 |
# max_tokens generated by the AI model
|
162 |
# maximu value can be 4096 tokens for "gpt-3.5-turbo"
|
163 |
max_tokens = MaxToken,
|