Spaces:
Paused
Paused
dharmendra
commited on
Commit
·
34826da
1
Parent(s):
0cb7726
14july
Browse files
app.py
CHANGED
@@ -48,8 +48,9 @@ llm = HuggingFacePipeline(pipeline=pipeline(
|
|
48 |
tokenizer=tokenizer,
|
49 |
max_new_tokens=512, # Adjust as needed for desired response length
|
50 |
return_full_text=False, # Crucial for getting only the AI's response, esp when ans is small
|
51 |
-
temperature=0.
|
52 |
do_sample=True # Enable sampling for more varied outputs
|
|
|
53 |
))
|
54 |
|
55 |
template = """The following is a concise and direct conversation between a human and an AI.
|
@@ -113,7 +114,7 @@ async def generate_text(request: QuestionRequest):
|
|
113 |
# Return a StreamingResponse, which will send chunks as they are yielded by generate_stream()
|
114 |
# media_type can be "text/event-stream" for SSE, or "text/plain" for simple newline-delimited text.
|
115 |
# For simplicity, we'll start with "text/plain" for easier initial client parsing.
|
116 |
-
return StreamingResponse(generate_stream(), media_type="
|
117 |
|
118 |
|
119 |
|
|
|
48 |
tokenizer=tokenizer,
|
49 |
max_new_tokens=512, # Adjust as needed for desired response length
|
50 |
return_full_text=False, # Crucial for getting only the AI's response, esp when ans is small
|
51 |
+
temperature=0.2, # Controls randomness (0.0 for deterministic, 1.0 for very creative)
|
52 |
do_sample=True # Enable sampling for more varied outputs
|
53 |
+
stop_sequence=["Human:", "AI:", "\nHuman:", "\nAI:"] #to prevent gen unwanted conversations
|
54 |
))
|
55 |
|
56 |
template = """The following is a concise and direct conversation between a human and an AI.
|
|
|
114 |
# Return a StreamingResponse, which will send chunks as they are yielded by generate_stream()
|
115 |
# media_type can be "text/event-stream" for SSE, or "text/plain" for simple newline-delimited text.
|
116 |
# For simplicity, we'll start with "text/plain" for easier initial client parsing.
|
117 |
+
return StreamingResponse(generate_stream(), media_type="application/json")
|
118 |
|
119 |
|
120 |
|