Spaces:
Runtime error
Runtime error
File size: 2,612 Bytes
c595ba7 acd6dc5 af7fd9b acd6dc5 9498171 acd6dc5 9498171 9c46c22 c595ba7 9498171 1665886 9498171 c595ba7 9498171 |
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 53 54 55 56 57 |
import gradio as gr
from paperqa import Docs, SentenceTransformerEmbeddingModel
from langchain_anthropic import ChatAnthropic
MODEL_NAME = "claude-3-5-sonnet-20240620"
class MyChatAnthropic(ChatAnthropic):
model_name: str = MODEL_NAME
llm = MyChatAnthropic(
model=MODEL_NAME,
temperature=0.2,
max_tokens=4096,)
class MyEmb(SentenceTransformerEmbeddingModel):
async def aembed_documents(self, texts):
return await self.embed_documents(None, texts)
emb = MyEmb(model_name="mixedbread-ai/mxbai-embed-large-v1")
docs = Docs(llm="langchain",
embedding="langchain",
embedding_client=emb,
client=llm)
docs.max_concurrent = 1
docs.add('knowledge_extraction.csv', disable_check=True)
docs.add('SSA - POMS_ SI 00502.100 - Basic SSI Alien Eligibility Requirements - 11_30_2023.pdf', disable_check=True)
def respond(message, *args, **kwargs):
return docs.query(message).answer
examples = [["A qualified alien entered the United States on August 15, 1996. Tell me about their eligibility for Supplemental Security Income (SSI)."],
["""Question: Which of the following statements most accurately reflects the eligibility requirements for Supplemental Security Income (SSI) as outlined in the Alien Eligibility Under Welfare Reform?
A) To be eligible for SSI, an individual must be a U.S. citizen, with no exceptions for non-citizens.
B) SSI eligibility is extended to all individuals residing in the United States, regardless of their citizenship or immigration status.
C) To be eligible for SSI, an individual must be either a U.S. citizen or a qualified alien.
D) SSI eligibility is determined solely based on financial need, without consideration of citizenship or immigration status."""],
["""Explanate the Correct Answer: C
Question: Which of the following statements most accurately reflects the eligibility requirements for Supplemental Security Income (SSI) as outlined in the Alien Eligibility Under Welfare Reform?
A) To be eligible for SSI, an individual must be a U.S. citizen, with no exceptions for non-citizens.
B) SSI eligibility is extended to all individuals residing in the United States, regardless of their citizenship or immigration status.
C) To be eligible for SSI, an individual must be either a U.S. citizen or a qualified alien.
D) SSI eligibility is determined solely based on financial need, without consideration of citizenship or immigration status."""]]
demo = gr.ChatInterface(
respond,
examples=examples)
if __name__ == "__main__":
demo.launch(auth=("tester", "8888p4ss")) |