generated from CogitoNTNU/README-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into astream_events_experiment
- Loading branch information
Showing
21 changed files
with
184 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
OPENAI_API_KEY="your_api_key" | ||
LANGSMITH_API_KEY="your_langsmith_api_key" #Find it here: https://smith.langchain.com | ||
PORT="3000" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
name: CD | ||
|
||
on: | ||
workflow_run: | ||
workflows: ["CI"] | ||
types: | ||
- completed | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
# Only runs if CI was successful | ||
if: ${{ github.event.workflow_run.conclusion == 'success' }} | ||
|
||
steps: | ||
# Checkout the repository | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v2 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
- name: Log in to GitHub Container Registry | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Extract short SHA | ||
id: git_sha | ||
run: echo "GIT_SHA=$(git rev-parse --short $GITHUB_SHA)" >> $GITHUB_ENV | ||
|
||
- name: Build and Push Docker Backend Image | ||
run: | | ||
docker build -t ghcr.io/cogitontnu/jarvis-core:${{ env.GIT_SHA }} ./core | ||
docker push ghcr.io/cogitontnu/jarvis-core:${{ env.GIT_SHA }} | ||
## Add Build and Push for Docker Frontend Image when it becomes relevant |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches: ["main"] | ||
pull_request: | ||
branches: ["main"] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: true | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Build docker image and run tests | ||
run: | | ||
docker compose build | ||
docker compose up -d | ||
docker compose down |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
# Custom Ignores | ||
user_data | ||
|
||
|
||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
### Benchmarking | ||
Standardized tasks and tests for Jarvis to evaluate performance. | ||
Standardized tasks and tests for Jarvis to evaluate performance. | ||
|
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from langchain_openai import ChatOpenAI | ||
from models import Model | ||
from config import OPENAI_API_KEY | ||
|
||
|
||
class SimpleAgent: | ||
llm = ChatOpenAI( | ||
model = Model.gpt_4o, | ||
temperature=0, | ||
max_tokens=512, | ||
streaming=True | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
class Ai_message: | ||
def __init__(self, message:str, token_count:int) -> None: | ||
self.message = message | ||
self.token_count = token_count | ||
self.token_count = token_count |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import os | ||
import json | ||
|
||
def read_chat(id: str) -> dict: | ||
''' | ||
Uses chat_id to get the chat JSON file and returns a python dict object. | ||
''' | ||
dirname = os.path.dirname(os.path.dirname(__file__)) # Creates folder in core named user_data | ||
filepath = os.path.join(dirname, f'user_data/chats/{id}.json') | ||
# Open and read the JSON file | ||
with open(filepath, 'r') as file: | ||
data = json.load(file) | ||
return data | ||
|
||
def upsert_chat(chat_object: dict): | ||
''' | ||
Upserts a chat dictionary object, saving it as json file in the user_data folder. | ||
Upserting means to update or create if the file doesn't exist yet. Overwriting previous data. | ||
''' | ||
try: | ||
print("hey") | ||
except Exception as e: | ||
return e | ||
|
||
|
||
# json.dumps() - From python to json | ||
# json.load() - From json to python |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import os | ||
|
||
def check_folders(): | ||
main_folder = "user_data/" | ||
pathsToCheck = ["chats", "images", "pdfs", "fbx"] | ||
for directory in pathsToCheck: | ||
path = main_folder + directory # creates path user_data/chats for example. Everything should be under user_data as its gitignored. | ||
check_and_create_folder(path) # Does a relative folder check, and builds the directory if it doesn't exist | ||
|
||
def check_and_create_folder(path): | ||
dirname = os.path.dirname(os.path.dirname(__file__)) # Creates folder in core named user_data | ||
relativedir = os.path.join(dirname, path) | ||
if not os.path.exists(relativedir): | ||
try: | ||
print("Created user_data director under core folder. This is first-time setup.") | ||
os.makedirs(path) | ||
except Exception as e: | ||
print(e) |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.