File size: 1,120 Bytes
0a07732 c4b57ef 0a07732 c297558 0a07732 d03ad5d 0a07732 c4b57ef dde9562 c4b57ef d3bf19f cd66d08 c4b57ef 0a07732 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
import gradio as gr
import requests
from g4f import Provider, models
from langchain.llms.base import LLM
from langchain_g4f import G4FLLM
url = "https://app.embedchain.ai/api/v1/pipelines/f14b3df8-db63-456c-8a7f-4323b4467271/context/"
def greet(name):
payload = {
"query": f"{name}",
"count": 10
}
headers = {
'Authorization': 'Token ec-pbVFWamfNAciPwb18ZwaQkKKUCCBnafko9ydl3Y5',
}
response = requests.request("POST", url, headers=headers, json=payload)
print(name)
c = response.text
llm = LLM = G4FLLM(
model=models.gpt_35_turbo,
provider=Provider.GeekGpt,
)
res = llm(f"""
Use the following pieces of context to answer the query at the end.
If you don't know the answer, just say that you don't know, don't try to make up an answer.
${c}
Query: ${name}
Helpful Answer:
system_prompt: |
Act as William Shakespeare. Answer the following questions in the style of William Shakespeare.
""")
print(res)
return res
iface = gr.Interface(fn=greet, inputs="text", outputs="text")
iface.launch() |