Petro commited on
Commit
bc985a0
1 Parent(s): 273463a
Files changed (3) hide show
  1. Dockerfile +0 -2
  2. main.py +13 -6
  3. requirements.txt +1 -1
Dockerfile CHANGED
@@ -1,7 +1,5 @@
1
  FROM python:3.9
2
 
3
- RUN wget -q zephyr-7b-beta.Q4_K_S.gguf https://huggingface.co/TheBloke/zephyr-7B-beta-GGUF/resolve/main/zephyr-7b-beta.Q4_K_S.gguf
4
-
5
  COPY requirements.txt ./requirements.txt
6
 
7
  RUN python -m pip install -U pip && \
 
1
  FROM python:3.9
2
 
 
 
3
  COPY requirements.txt ./requirements.txt
4
 
5
  RUN python -m pip install -U pip && \
main.py CHANGED
@@ -1,13 +1,20 @@
 
 
1
  from ctransformers import AutoModelForCausalLM
2
  from fastapi import FastAPI
3
  from pydantic import BaseModel
4
  import requests
5
- #
6
- # llm = AutoModelForCausalLM.from_pretrained("zephyr-7b-beta.Q4_K_S.gguf",
7
- # model_type='mistral',
8
- # max_new_tokens = 1096,
9
- # threads = 3,
10
- # )
 
 
 
 
 
11
 
12
  #Pydantic object
13
  class validation(BaseModel):
 
1
+ import os
2
+
3
  from ctransformers import AutoModelForCausalLM
4
  from fastapi import FastAPI
5
  from pydantic import BaseModel
6
  import requests
7
+ from huggingface_hub import hf_hub_download
8
+
9
+ file_name = "zephyr-7b-beta.Q4_K_S.gguf"
10
+ if not os.path.exists(file_name):
11
+ hf_hub_download("TheBloke/zephyr-7B-beta-GGUF", filename=file_name, local_dir=f"./")
12
+
13
+ llm = AutoModelForCausalLM.from_pretrained(file_name,
14
+ model_type='mistral',
15
+ max_new_tokens = 1096,
16
+ threads = 3,
17
+ )
18
 
19
  #Pydantic object
20
  class validation(BaseModel):
requirements.txt CHANGED
@@ -5,4 +5,4 @@ uvicorn
5
  requests
6
  python-dotenv
7
  ctransformers
8
- requests
 
5
  requests
6
  python-dotenv
7
  ctransformers
8
+ huggingface-hub