forked from cohere-ai/cohere-toolkit
-
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.
readme: add Azure deployment description + single Docker improvements…
… and fixes (cohere-ai#76) * readme: add Azure deploy description + single Docker improvements * readme: add Azure deploy description + single Docker improvements * Add Sqlite v.3.45.3 for Chroma DB deployment: add docker compose down command in Makefile. (cohere-ai#65) Signed-off-by: ifuryst <ifuryst@gmail.com> coral_web: Add is_available check to tools (cohere-ai#82) * add is_available check to tools * add tool error message as tooltip * disable unavailable tools, show error message if description does not exist Setup: fix key error (cohere-ai#84) docs: Update README.md links (cohere-ai#83) Update README.md links Some links were still pointing to the old `cohere-ia/toolkit` repository, instead of `cohere-ai/cohere-toolkit`. docs: clarify setup env for development. (cohere-ai#64) Signed-off-by: ifuryst <ifuryst@gmail.com> coral-web: update the starter card options (cohere-ai#73) * add new start options * set start option prompts * clean up * remove welcome message * remove notification message * visual nits * center start options, fade out when convo is populated * remove streaming message check coral-web: include conversationId in file upload (cohere-ai#85) include conversationId in file upload Deployment: add local model deployment option (cohere-ai#77) * Deployment: add local model deployment option * lint * add tests * lint * fix cohere prompts Docs: add env setup instructions (cohere-ai#88) Cli: add dummy tests (cohere-ai#89) * Cli: add dummy tests * move cli to backend backend: Set up next.js to proxy requests to the API (cohere-ai#86) Set up next.js to proxy requests to the API tools: Update default NEXT_PUBLIC_API_HOSTNAME for the new api routing (cohere-ai#94) * Update default NEXT_PUBLIC_API_HOSTNAME for the new api routing * Also update NEXT_PUBLIC_API_HOSTNAME in README and .env-template fix: broken backend URL in cli (cohere-ai#93) Update main.py Co-authored-by: Tianjing Li <tianjinglimail@gmail.com> changed logo and pager header implemented openAI adapter added env variable for oai key implemented working chatgpt 1 fixed fix fixed conversation order bug fixed bugs with incorrect chat history. added exrract script other changes to msgs msgRow has text duplication bug fix? big update pls close! cool cool font change big fixes for message row highlight selection now working perfectly. small fix for code selection (remaining bug in nodes textContent tooltip) big commit big commit HUGE bug fix for laggy composer ! HUGE bug fix for laggy composer ! implemented annotation prompting less spam working annotaiton schema setup WORKING annotation saving! working annotation saving in db huge update, cookies, ua and many fixes for highlights
- Loading branch information
1 parent
2764fc2
commit 2503714
Showing
83 changed files
with
4,638 additions
and
660 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
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
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,77 @@ | ||
from src.backend.crud.conversation import extract_conversations, Conversation | ||
|
||
from dotenv import load_dotenv | ||
from sqlalchemy import create_engine, text | ||
from sqlalchemy.orm import Session, sessionmaker | ||
|
||
import json | ||
from datetime import datetime | ||
|
||
load_dotenv() | ||
|
||
SQLALCHEMY_DATABASE_URL = "postgresql+psycopg2://postgres:postgres@localhost:5433" | ||
|
||
engine = create_engine( | ||
SQLALCHEMY_DATABASE_URL, echo=False | ||
) | ||
|
||
db = Session(autocommit=False, autoflush=False, bind=engine) | ||
|
||
def run_script(): | ||
|
||
""" | ||
Saves all conversations in the database in format: | ||
\n`conv_id` : {conversation attributes} | ||
""" | ||
|
||
conversations = extract_conversations(db) | ||
|
||
file_path = "conversations.txt" | ||
|
||
data = {} | ||
|
||
#Format the data and assemble the new conversation dictionary | ||
for conv in conversations: | ||
|
||
id, p_conv = parse_conversation(conv) | ||
data[id] = p_conv | ||
|
||
print(conversations[-1].description) | ||
print(conversations[-1].messages[-1].text) | ||
|
||
#Save it | ||
with open(file_path, "w") as file: | ||
json.dump(data, file) | ||
|
||
print(f"Succesfully saved file at {file_path}! Saved {len(conversations)} conversations!") | ||
print("Checking if data can be successfully loaded . . .") | ||
|
||
#Check to see if we can load data without errors. | ||
try: | ||
with open(file_path, "r") as file: | ||
loaded_data = json.load(file) | ||
print("Sucess!") | ||
except Exception as e: | ||
print("We were unable to load the data, this means it isnt being saved properly and is corrupted.") | ||
print(f"Error message: {e}") | ||
|
||
#Turns a conversation into something we can store. | ||
def parse_conversation(conv : Conversation) -> tuple[str, dict]: | ||
""" | ||
Returns a conversation_id and dictionary of all conversation data. | ||
""" | ||
|
||
parsed_messages = [{'role' : msg.agent, 'text' : msg.text, 'm_id' : msg.id, 'annotations' : [{'a_id' : annot.id, 'htext' : annot.htext, 'annotation' : annot.annotation, 'start' : annot.start, 'end' : annot.end} for annot in msg.annotations], 'position' : msg.position} for msg in conv.messages] | ||
|
||
return conv.id, { | ||
'date' : conv.created_at.strftime("%Y-%m-%d"), | ||
'user_id' : conv.user_id, | ||
'messages' : parsed_messages | ||
} | ||
|
||
if __name__ == "__main__": | ||
run_script() |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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.