daniellefranca96 commited on
Commit
37c38ea
1 Parent(s): 7a70898

first commit

Browse files
Files changed (5) hide show
  1. .gitattributes +1 -0
  2. Dockerfile +15 -0
  3. main.py +19 -0
  4. requirements.txt +3 -0
  5. tinyllama-1.1b-chat.gguf +3 -0
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ tinyllama-1.1b-chat.gguf filter=lfs diff=lfs merge=lfs -text
Dockerfile ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.9
2
+
3
+ WORKDIR /code
4
+
5
+ ENV HF_HOME=/code/.cache
6
+
7
+ COPY ./requirements.txt /code/requirements.txt
8
+ COPY ./main.py /code/main.py
9
+ COPY ./tinyllama-1.1b-chat.gguf ./tinyllama-1.1b-chat.gguf
10
+
11
+ RUN mkdir -p /code/.cache && chmod -R 777 /code/.cache
12
+
13
+ RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
14
+
15
+ CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
main.py ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastapi import FastAPI
2
+ import requests
3
+ from llama_cpp import Llama
4
+
5
+ app = FastAPI()
6
+
7
+ llm = Llama(model_path="./tinyllama-1.1b-chat.gguf")
8
+
9
+ @app.post("/llm")
10
+ async def stream(item: dict):
11
+
12
+ if 'prompt' not in item.keys():
13
+ raise ValueError("prompt é obrigatório")
14
+
15
+ prompt = item['prompt']
16
+ temperatura = item['temperatura'] if 'temperatura' in item.keys() else 0.2
17
+ max_tokens = item['max_tokens'] if 'max_tokens' in item.keys() else 512
18
+
19
+ return llm(prompt, max_tokens=max_tokens, temperature=temperatura)
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ llama-cpp-python
2
+ langchain
3
+ fastapi
tinyllama-1.1b-chat.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9fecc3b3cd76bba89d504f29b616eedf7da85b96540e490ca5824d3f7d2776a0
3
+ size 668788096