Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,5 +1,8 @@
|
|
| 1 |
import io
|
| 2 |
import os
|
|
|
|
|
|
|
|
|
|
| 3 |
import ssl
|
| 4 |
from contextlib import closing
|
| 5 |
from typing import Optional, Tuple
|
|
@@ -17,7 +20,8 @@ from langchain import ConversationChain, LLMChain
|
|
| 17 |
|
| 18 |
from langchain.agents import load_tools, initialize_agent
|
| 19 |
from langchain.chains.conversation.memory import ConversationBufferMemory
|
| 20 |
-
from langchain.llms import OpenAI
|
|
|
|
| 21 |
from threading import Lock
|
| 22 |
|
| 23 |
# Console to variable
|
|
@@ -48,7 +52,7 @@ tmdb_bearer_token = os.environ["TMDB_BEARER_TOKEN"]
|
|
| 48 |
|
| 49 |
TOOLS_LIST = ['serpapi', 'wolfram-alpha', 'pal-math', 'pal-colored-objects', 'news-api'] #'google-search','news-api','tmdb-api','open-meteo-api'
|
| 50 |
TOOLS_DEFAULT_LIST = ['serpapi', 'wolfram-alpha', 'pal-math', 'pal-colored-objects', 'news-api']
|
| 51 |
-
BUG_FOUND_MSG = "
|
| 52 |
# AUTH_ERR_MSG = "Please paste your OpenAI key from openai.com to use this application. It is not necessary to hit a button or key after pasting it."
|
| 53 |
AUTH_ERR_MSG = "Please paste your OpenAI key from openai.com to use this application. "
|
| 54 |
MAX_TOKENS = 2048
|
|
@@ -285,6 +289,7 @@ def set_openai_api_key(api_key):
|
|
| 285 |
return chain, express_chain, llm, embeddings, qa_chain, memory
|
| 286 |
return None, None, None, None, None, None
|
| 287 |
|
|
|
|
| 288 |
|
| 289 |
def run_chain(chain, inp, capture_hidden_text):
|
| 290 |
output = ""
|
|
|
|
| 1 |
import io
|
| 2 |
import os
|
| 3 |
+
import promptlayer
|
| 4 |
+
promptlayer.api_key = os.environ.get("PROMPTLAYER_KEY")
|
| 5 |
+
|
| 6 |
import ssl
|
| 7 |
from contextlib import closing
|
| 8 |
from typing import Optional, Tuple
|
|
|
|
| 20 |
|
| 21 |
from langchain.agents import load_tools, initialize_agent
|
| 22 |
from langchain.chains.conversation.memory import ConversationBufferMemory
|
| 23 |
+
# from langchain.llms import OpenAI
|
| 24 |
+
from promptlayer.langchain.llms import OpenAI
|
| 25 |
from threading import Lock
|
| 26 |
|
| 27 |
# Console to variable
|
|
|
|
| 52 |
|
| 53 |
TOOLS_LIST = ['serpapi', 'wolfram-alpha', 'pal-math', 'pal-colored-objects', 'news-api'] #'google-search','news-api','tmdb-api','open-meteo-api'
|
| 54 |
TOOLS_DEFAULT_LIST = ['serpapi', 'wolfram-alpha', 'pal-math', 'pal-colored-objects', 'news-api']
|
| 55 |
+
BUG_FOUND_MSG = "Error in the return response. Please try again."
|
| 56 |
# AUTH_ERR_MSG = "Please paste your OpenAI key from openai.com to use this application. It is not necessary to hit a button or key after pasting it."
|
| 57 |
AUTH_ERR_MSG = "Please paste your OpenAI key from openai.com to use this application. "
|
| 58 |
MAX_TOKENS = 2048
|
|
|
|
| 289 |
return chain, express_chain, llm, embeddings, qa_chain, memory
|
| 290 |
return None, None, None, None, None, None
|
| 291 |
|
| 292 |
+
PROMPTLAYER_API_BASE = "https://api.promptlayer.com"
|
| 293 |
|
| 294 |
def run_chain(chain, inp, capture_hidden_text):
|
| 295 |
output = ""
|