diff options
author | noptuno <repollo.marrero@gmail.com> | 2023-04-28 02:40:47 +0200 |
---|---|---|
committer | noptuno <repollo.marrero@gmail.com> | 2023-04-28 02:40:47 +0200 |
commit | 6f6a73987201c9c303047c61389b82ad98b15597 (patch) | |
tree | bf67eb590d49979d6740bc1e94b4018df48bce98 /gui | |
parent | Resolved merge conflicts and merged pr_218 into STREAMLIT_CHAT_IMPLEMENTATION (diff) | |
parent | Merging PR_218 openai_rev package with new streamlit chat app (diff) | |
download | gpt4free-6f6a73987201c9c303047c61389b82ad98b15597.tar gpt4free-6f6a73987201c9c303047c61389b82ad98b15597.tar.gz gpt4free-6f6a73987201c9c303047c61389b82ad98b15597.tar.bz2 gpt4free-6f6a73987201c9c303047c61389b82ad98b15597.tar.lz gpt4free-6f6a73987201c9c303047c61389b82ad98b15597.tar.xz gpt4free-6f6a73987201c9c303047c61389b82ad98b15597.tar.zst gpt4free-6f6a73987201c9c303047c61389b82ad98b15597.zip |
Diffstat (limited to '')
-rw-r--r-- | gui/query_methods.py | 9 | ||||
-rw-r--r-- | gui/streamlit_app.py | 23 | ||||
-rw-r--r-- | gui/streamlit_chat_app.py | 3 |
3 files changed, 17 insertions, 18 deletions
diff --git a/gui/query_methods.py b/gui/query_methods.py index fbbdb657..08a81b64 100644 --- a/gui/query_methods.py +++ b/gui/query_methods.py @@ -1,8 +1,8 @@ -import forefront, quora, theb, you +import openai_rev +from openai_rev import forefront, quora, theb, you import random - def query_forefront(question: str) -> str: # create an account token = forefront.Account.create(logging=True) @@ -47,8 +47,7 @@ def query_you(question: str) -> str: try: result = you.Completion.create( prompt = question) - - return result['response'] + return result.text except Exception as e: # Return error message if an exception occurs @@ -57,7 +56,7 @@ def query_you(question: str) -> str: # Define a dictionary containing all query methods avail_query_methods = { "Forefront": query_forefront, - "Quora": query_quora, + "Poe": query_quora, "Theb": query_theb, "You": query_you, # "Writesonic": query_writesonic, diff --git a/gui/streamlit_app.py b/gui/streamlit_app.py index 4e0a618d..2bbf86e0 100644 --- a/gui/streamlit_app.py +++ b/gui/streamlit_app.py @@ -4,19 +4,21 @@ import sys sys.path.append(os.path.join(os.path.dirname(__file__), os.path.pardir)) import streamlit as st -import you +from openai_rev import you + def get_answer(question: str) -> str: # Set cloudflare clearance cookie and get answer from GPT-4 model try: - result = you.Completion.create( - prompt = question) - - return result['response'] - + result = you.Completion.create(prompt=question) + + return result.text + except Exception as e: # Return error message if an exception occurs - return f'An error occurred: {e}. Please make sure you are using a valid cloudflare clearance token and user agent.' + return ( + f'An error occurred: {e}. Please make sure you are using a valid cloudflare clearance token and user agent.' + ) # Set page configuration and add header @@ -27,14 +29,13 @@ st.set_page_config( menu_items={ 'Get Help': 'https://github.com/xtekky/gpt4free/blob/main/README.md', 'Report a bug': "https://github.com/xtekky/gpt4free/issues", - 'About': "### gptfree GUI" - } + 'About': "### gptfree GUI", + }, ) st.header('GPT4free GUI') # Add text area for user input and button to get answer -question_text_area = st.text_area( - '🤖 Ask Any Question :', placeholder='Explain quantum computing in 50 words') +question_text_area = st.text_area('🤖 Ask Any Question :', placeholder='Explain quantum computing in 50 words') if st.button('🧠Think'): answer = get_answer(question_text_area) # Display answer diff --git a/gui/streamlit_chat_app.py b/gui/streamlit_chat_app.py index 3ced571a..09d53bcf 100644 --- a/gui/streamlit_chat_app.py +++ b/gui/streamlit_chat_app.py @@ -74,8 +74,7 @@ if st.sidebar.button("New Conversation"): print(openai_rev.Provider.__methods__.keys()) st.session_state['query_method'] = st.sidebar.selectbox( "Select API:", - - options=avail_query_methods.keys(), + options=openai_rev.Provider.__members__.keys(), index=0 ) |