richardblythman commited on
Commit
2029b44
1 Parent(s): 671a955

Upload folder using huggingface_hub

Browse files
Files changed (6) hide show
  1. README.md +0 -0
  2. chat/__init__.py +0 -0
  3. chat/component.yaml +24 -0
  4. chat/run.py +23 -0
  5. pyproject.toml +14 -0
  6. tests/__init__.py +0 -0
README.md ADDED
File without changes
chat/__init__.py ADDED
File without changes
chat/component.yaml ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ author: richardblythman
2
+ description: chat
3
+ implementation:
4
+ package:
5
+ entrypoint: run.py
6
+ inputs:
7
+ location: node
8
+ save: 'false'
9
+ system_message: You are a helpful AI assistant.
10
+ license: MIT
11
+ models:
12
+ default_model_provider: ollama
13
+ ollama:
14
+ api_base: http://localhost:11434
15
+ max_tokens: 1000
16
+ model: ollama/phi
17
+ temperature: 0
18
+ name: chat
19
+ outputs:
20
+ filename: output.txt
21
+ location: node
22
+ save: 'false'
23
+ type: chat
24
+ version: 0.1.0
chat/run.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from naptha_sdk.utils import get_logger
2
+
3
+ logger = get_logger(__name__)
4
+
5
+ def run(inputs, worker_nodes = None, orchestrator_node = None, flow_run = None, cfg: dict = None):
6
+ @app.agent_service("chat_receiver", "http://node1.naptha.ai:7001")
7
+ def chat(inputs):
8
+ from litellm import completion
9
+ prompt = inputs
10
+ messages = [
11
+ {"role": "system", "content": "You are a helpful AI assistant."},
12
+ {"role": "user", "content": prompt},
13
+ ]
14
+ response = completion(
15
+ model="ollama/phi",
16
+ messages=messages,
17
+ temperature=0,
18
+ max_tokens=1000,
19
+ api_base="http://localhost:11434",
20
+ )
21
+ response = response.choices[0].message["content"]
22
+ logger.info(f"Response: {response}")
23
+ return response
pyproject.toml ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [tool.poetry]
2
+ name = "chat"
3
+ version = "0.1.0"
4
+ description = ""
5
+ authors = ["Your Name <[email protected]>"]
6
+ readme = "README.md"
7
+
8
+ [tool.poetry.dependencies]
9
+ python = "^3.12"
10
+
11
+
12
+ [build-system]
13
+ requires = ["poetry-core"]
14
+ build-backend = "poetry.core.masonry.api"
tests/__init__.py ADDED
File without changes