vincentmin commited on
Commit
45e331f
·
1 Parent(s): 9b01f45

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -29,7 +29,7 @@ document_prompt = PromptTemplate(
29
  )
30
  prompt = PromptTemplate(
31
  template=
32
- """Write a personalised newsletter for a researcher. The researcher describes his work as follows:"{context}". Base the newsletter on the following articles:\n\n"{text}"\n\nNEWSLETTER:""",
33
  input_variables=["context", "text"])
34
 
35
  # llm = FakeListLLM(responses=list(map(str, range(100))))
@@ -37,7 +37,7 @@ REPO_ID = "HuggingFaceH4/starchat-beta"
37
  llm = HuggingFaceHub(
38
  repo_id=REPO_ID,
39
  model_kwargs={
40
- "max_new_tokens": 1024,
41
  "do_sample": True,
42
  "temperature": 0.8,
43
  "top_p": 0.9
@@ -68,7 +68,8 @@ def get_data(user_query: str):
68
  for doc in relevant_docs:
69
  articles += f"**Title: {doc.metadata['Title']}**\n\nAbstract: {doc.metadata['Summary']}\n\n"
70
  output = stuff_chain({"input_documents": relevant_docs, "context": user_query})
71
- return f"{output['output_text']}\n\n\n\nUsed articles:\n\n{output}"
 
72
 
73
  demo = gr.Interface(
74
  fn=get_data,
 
29
  )
30
  prompt = PromptTemplate(
31
  template=
32
+ """Write a personalised newsletter for a researcher. The researcher describes his work as follows:"{context}". Base the newsletter on the following articles:\n\n"{text}"\n\nNEWSLETTER:\n#Your AI curated newsletter\n""",
33
  input_variables=["context", "text"])
34
 
35
  # llm = FakeListLLM(responses=list(map(str, range(100))))
 
37
  llm = HuggingFaceHub(
38
  repo_id=REPO_ID,
39
  model_kwargs={
40
+ "max_new_tokens": 300,
41
  "do_sample": True,
42
  "temperature": 0.8,
43
  "top_p": 0.9
 
68
  for doc in relevant_docs:
69
  articles += f"**Title: {doc.metadata['Title']}**\n\nAbstract: {doc.metadata['Summary']}\n\n"
70
  output = stuff_chain({"input_documents": relevant_docs, "context": user_query})
71
+ output_text = output["output_text"].split("<|end|>")[0]
72
+ return f"#Your AI curated newsletter\n{output['output_text']}\n\n\n\nUsed articles:\n\n{articles}"
73
 
74
  demo = gr.Interface(
75
  fn=get_data,