Created
November 10, 2023 16:17
-
-
Save mberman84/a1291cfb08d0a37c3d439028f3bc5f26 to your computer and use it in GitHub Desktop.
OpenChat Code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import json | |
import gradio as gr | |
url = "http://localhost:11434/api/generate" | |
headers = { | |
'Content-Type': 'application/json', | |
} | |
conversation_history = [] | |
def generate_response(prompt): | |
conversation_history.append(prompt) | |
full_prompt = "\n".join(conversation_history) | |
data = { | |
"model": "mistral", | |
"stream": False, | |
"prompt": full_prompt, | |
} | |
response = requests.post(url, headers=headers, data=json.dumps(data)) | |
if response.status_code == 200: | |
response_text = response.text | |
data = json.loads(response_text) | |
actual_response = data["response"] | |
conversation_history.append(actual_response) | |
return actual_response | |
else: | |
print("Error:", response.status_code, response.text) | |
return None | |
iface = gr.Interface( | |
fn=generate_response, | |
inputs=gr.inputs.Textbox(lines=2, placeholder="Enter your prompt here..."), | |
outputs="text" | |
) | |
iface.launch() |
bibop,
I had this same issue. I am using gradio version 4.2.0. To fix this issue I had to change the code on line 38 from
inputs=gr.inputs.Textbox(lines=2, placeholder="Enter your prompt here..."),
to
inputs="text",
Hope that helps.
Change line 38
to:
inputs=gr.Textbox(lines=2, placeholder="Enter your prompt here..."),
im getting: ValueError: When localhost is not accessible, a shareable link must be created. Please set share=True or check your proxy settings to allow access to localhost.
Change line
38
to:inputs=gr.Textbox(lines=2, placeholder="Enter your prompt here..."),
Hey thanks @TerrenceMiao , it is working
It worked!! Thanks a lot!!!
…________________________________
Da: nulltermin8d ***@***.***>
Inviato: sabato, novembre 11, 2023 5:32 PM
A: nulltermin8d ***@***.***>
Cc: Comment ***@***.***>
Oggetto: Re: mberman84/main.py
@nulltermin8d commented on this gist.
________________________________
bibop,
I had this same issue. I am using gradio version 4.2.0. To fix this issue I had to change the code on line 38 from
inputs=gr.inputs.Textbox(lines=2, placeholder="Enter your prompt here..."),
to
inputs="text",
Hope that helps.
—
Reply to this email directly, view it on GitHub<https://urldefense.proofpoint.com/v2/url?u=https-3A__gist.github.com_mberman84_a1291cfb08d0a37c3d439028f3bc5f26-23gistcomment-2D4757634&d=DwMFaQ&c=euGZstcaTDllvimEN8b7jXrwqOf-v5A_CdpgnVfiiMM&r=G2sZnGjMxZyAsUj9FM1uvQ&m=fnu5BfjJ1BcqmNkvFihaUbTICYVe8GfgEnsPH8WKuZY6EAqwV2YkW1ZVRXQ9StOR&s=7W5T2HJPQUvufXZz9q9ZOXWfqse_efhVXAhdkrd8VfY&e=> or unsubscribe<https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_notifications_unsubscribe-2Dauth_ABK2T6KO7UQYFCFNQ5JLJATYD6SC5BFKMF2HI4TJMJ2XIZLTSKBKK5TBNR2WLJDHNFZXJJDOMFWWLK3UNBZGKYLEL52HS4DFQKSXMYLMOVS2I5DSOVS2I3TBNVS3W5DIOJSWCZC7OBQXE5DJMNUXAYLOORPWCY3UNF3GS5DZVRZXKYTKMVRXIX3UPFYGLK2HNFZXIQ3PNVWWK3TUUZ2G64DJMNZZDAVEOR4XAZNEM5UXG5FFOZQWY5LFVEYTENRRGUYDMNZTU52HE2LHM5SXFJTDOJSWC5DF&d=DwMFaQ&c=euGZstcaTDllvimEN8b7jXrwqOf-v5A_CdpgnVfiiMM&r=G2sZnGjMxZyAsUj9FM1uvQ&m=fnu5BfjJ1BcqmNkvFihaUbTICYVe8GfgEnsPH8WKuZY6EAqwV2YkW1ZVRXQ9StOR&s=Z3oaIFFEO5S_aEvwpdMCsuz8yCMPOpGr2zE2LeKRsVI&e=>.
You are receiving this email because you commented on the thread.
Triage notifications on the go with GitHub Mobile for iOS<https://urldefense.proofpoint.com/v2/url?u=https-3A__apps.apple.com_app_apple-2Dstore_id1477376905-3Fct-3Dnotification-2Demail-26mt-3D8-26pt-3D524675&d=DwMFaQ&c=euGZstcaTDllvimEN8b7jXrwqOf-v5A_CdpgnVfiiMM&r=G2sZnGjMxZyAsUj9FM1uvQ&m=fnu5BfjJ1BcqmNkvFihaUbTICYVe8GfgEnsPH8WKuZY6EAqwV2YkW1ZVRXQ9StOR&s=kZ8c28klf9WcsnkhC0up9v2_011vg2AQZwtEf2-xez0&e=> or Android<https://urldefense.proofpoint.com/v2/url?u=https-3A__play.google.com_store_apps_details-3Fid-3Dcom.github.android-26referrer-3Dutm-5Fcampaign-253Dnotification-2Demail-2526utm-5Fmedium-253Demail-2526utm-5Fsource-253Dgithub&d=DwMFaQ&c=euGZstcaTDllvimEN8b7jXrwqOf-v5A_CdpgnVfiiMM&r=G2sZnGjMxZyAsUj9FM1uvQ&m=fnu5BfjJ1BcqmNkvFihaUbTICYVe8GfgEnsPH8WKuZY6EAqwV2YkW1ZVRXQ9StOR&s=Out5pZP1jN7iXctr4NFx7zecHtUDf7WUKPAM1j_HLfM&e=>.
@nulltermin8d, yea that's what I needed! thanks! I am using Python 3.10.8 and Gradio 4.16.0
i have this error message :
ollama run mistral
pulling manifest
Error: pull model manifest: 403:
Your client does not have permission to get URL /token
from this server.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
(Mac Book Pro M2 - Visua Studio Code)
I followed all your steps and even if I have gradio correctly installed it gives me:
(base) bibop@BibopNewMacBook Ollama % /Users/bibop/.pyenv/versions/3.10.0/bin/python "/Users/bibop/Library/CloudStorage/
GoogleDrive-mrbibop@gmail.com/Il mio Drive/AI_Dev/Ollama/main.py"
Traceback (most recent call last):
File "/Users/bibop/Library/CloudStorage/GoogleDrive-mrbibop@gmail.com/Il mio Drive/AI_Dev/Ollama/main.py", line 38, in
inputs=gr.inputs.Textbox(lines=2, placeholder="Enter your prompt here..."),
AttributeError: module 'gradio' has no attribute 'inputs'
Any clue?