yashxx07 commited on
Commit
085c288
·
verified ·
1 Parent(s): 817a445

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +11 -19
main.py CHANGED
@@ -34,41 +34,33 @@ async def root():
34
  return {"status": "OK"}
35
 
36
 
 
37
  @app.post("/summarize-v1")
38
  async def root(item: Item):
39
-
40
  try:
41
-
42
  article = extract_article_content(item.url)
43
 
44
  if len(article) == 0:
45
  return {'summary': ""}
46
 
47
- for event in replicate.stream("snowflake/snowflake-arctic-instruct",input={
48
- "top_p": 0.9,
49
- "prompt": "Write fizz buzz in SQL",
50
- "temperature": 0.2,
51
- "max_new_tokens": 512,
52
- "min_new_tokens": 0,
53
- "stop_sequences": "<|im_end|>",
54
- "prompt_template": "<|im_start|>system\nYou're a helpful assistant<|im_end|>\n<|im_start|>user\n{prompt}<|im_end|>\n\n<|im_start|>assistant\n",
55
- "presence_penalty": 1.15,
56
- "frequency_penalty": 0.2},):
57
-
58
 
59
- output_variable = str(event)
60
- return {"summary":output_variable}
 
61
 
62
-
63
- return {"summary":""}
64
-
65
  except requests.RequestException as e:
66
  return {"error": str(e), "status_code": 500}
67
 
68
 
69
 
70
 
71
-
72
  # @app.post("/summarize-v2")
73
  # async def root(item: Item):
74
  # try:
 
34
  return {"status": "OK"}
35
 
36
 
37
+
38
  @app.post("/summarize-v1")
39
  async def root(item: Item):
 
40
  try:
 
41
  article = extract_article_content(item.url)
42
 
43
  if len(article) == 0:
44
  return {'summary': ""}
45
 
46
+ event_list = []
47
+ for event in replicate.stream("snowflake/snowflake-arctic-instruct", input={
48
+ prompt: "Write fizz buzz in SQL",
49
+ temperature: 0.2
50
+ }):
51
+ # Convert the event to a string and append it to the list
52
+ event_list.append(str(event))
 
 
 
 
53
 
54
+ # After the event stream ends, process the collected events
55
+ output_variable = "\n".join(event_list)
56
+ return {"summary": output_variable}
57
 
 
 
 
58
  except requests.RequestException as e:
59
  return {"error": str(e), "status_code": 500}
60
 
61
 
62
 
63
 
 
64
  # @app.post("/summarize-v2")
65
  # async def root(item: Item):
66
  # try: