aydayya commited on
Commit
f35e5d4
·
1 Parent(s): 30c18e5
Files changed (3) hide show
  1. Dockerfile +20 -0
  2. app.py +18 -0
  3. requirements.txt +3 -0
Dockerfile ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Use Python 3.9 image as a base
2
+ FROM python:3.9
3
+
4
+ # Create a non-root user to run the app
5
+ RUN useradd -m -u 1000 user
6
+ USER user
7
+ ENV PATH="/home/user/.local/bin:$PATH"
8
+
9
+ # Set the working directory inside the container
10
+ WORKDIR /app
11
+
12
+ # Install dependencies from the requirements.txt
13
+ COPY --chown=user ./requirements.txt requirements.txt
14
+ RUN pip install --no-cache-dir --upgrade -r requirements.txt
15
+
16
+ # Copy application files to the container
17
+ COPY --chown=user . /app
18
+
19
+ # Command to run FastAPI using Uvicorn
20
+ CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
app.py ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastapi import FastAPI
2
+ from ollama import chat
3
+ from ollama import ChatResponse
4
+
5
+ app = FastAPI()
6
+
7
+ # Route to interact with Ollama's chatbot
8
+ @app.get("/chat/{message}")
9
+ async def chat(message: str):
10
+ # Send a message to Ollama and get the response
11
+ response: ChatResponse = chat(
12
+ model="mohamedo/bignova", # Specify the model you want to use
13
+ messages=[{
14
+ 'role': 'user',
15
+ 'content': message
16
+ }]
17
+ )
18
+ return {"response": response['message']['content']}
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ fastapi
2
+ uvicorn[standard]
3
+ ollama