Spaces:
Runtime error
Runtime error
Damien Benveniste
commited on
Commit
·
5bbb821
1
Parent(s):
5eea5ad
latest
Browse files
app.py
CHANGED
@@ -1,3 +1,5 @@
|
|
|
|
|
|
1 |
from fastapi import FastAPI, Request, Response
|
2 |
from langserve import APIHandler
|
3 |
from langchain_huggingface import HuggingFaceEndpoint
|
@@ -9,14 +11,13 @@ def greet_json():
|
|
9 |
return {"Hello": "World!"}
|
10 |
|
11 |
|
12 |
-
|
13 |
llm = HuggingFaceEndpoint(
|
14 |
repo_id="meta-llama/Meta-Llama-3-8B-Instruct",
|
15 |
)
|
16 |
|
17 |
-
api_handler = APIHandler(llm)
|
18 |
|
19 |
|
20 |
-
@app.
|
21 |
async def simple_stream(request: Request):
|
22 |
return await api_handler.stream(request)
|
|
|
1 |
+
|
2 |
+
import os
|
3 |
from fastapi import FastAPI, Request, Response
|
4 |
from langserve import APIHandler
|
5 |
from langchain_huggingface import HuggingFaceEndpoint
|
|
|
11 |
return {"Hello": "World!"}
|
12 |
|
13 |
|
|
|
14 |
llm = HuggingFaceEndpoint(
|
15 |
repo_id="meta-llama/Meta-Llama-3-8B-Instruct",
|
16 |
)
|
17 |
|
18 |
+
api_handler = APIHandler(llm, path="/stream")
|
19 |
|
20 |
|
21 |
+
@app.post("/stream")
|
22 |
async def simple_stream(request: Request):
|
23 |
return await api_handler.stream(request)
|