ensure that we can call the new api.fc.archgw.com url, logging fixes … (#142)

* ensure that we can call the new api.fc.archgw.com url, logging fixes and minor cli bug fixes

* fixed a bug where model_server printed on terminal after start script stopped running

* updating the logo and fixing the website styles

* updated the branch with feedback from Co and Adil

---------

Co-authored-by: Salman Paracha <salmanparacha@MacBook-Pro-261.local>
This commit is contained in:
Salman Paracha 2024-10-08 12:40:24 -07:00 committed by GitHub
parent 82fc91495e
commit 3ed50e61d2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 70 additions and 47 deletions

View file

@ -4,21 +4,17 @@ from fastapi import FastAPI, Response
from .common import ChatMessage, Message
from .arch_handler import ArchHandler
from .bolt_handler import BoltHandler
from app.utils import load_yaml_config
import logging
import yaml
from app.utils import load_yaml_config, get_model_server_logger
from openai import OpenAI
import os
import hashlib
logging.basicConfig(
level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s"
)
logger = logging.getLogger(__name__)
logger = get_model_server_logger()
params = load_yaml_config("openai_params.yaml")
ollama_endpoint = os.getenv("OLLAMA_ENDPOINT", "localhost")
ollama_model = os.getenv("OLLAMA_MODEL", "Arch-Function-Calling-1.5B-Q4_K_M")
fc_url = os.getenv("FC_URL", "https://arch-fc-free-trial-4mzywewe.uc.gateway.dev/v1")
fc_url = os.getenv("FC_URL", "https://api.fc.archgw.com/v1")
mode = os.getenv("MODE", "cloud")
if mode not in ["cloud", "local-gpu", "local-cpu"]:
@ -52,7 +48,7 @@ logger.info(f"using endpoint: {endpoint}")
def process_state(arch_state, history: list[Message]):
print("state: {}".format(arch_state))
logger.info("state: {}".format(arch_state))
state_json = json.loads(arch_state)
state_map = {}
@ -61,7 +57,7 @@ def process_state(arch_state, history: list[Message]):
for tool_state in tools_state:
state_map[tool_state["key"]] = tool_state
print(f"state_map: {json.dumps(state_map)}")
logger.info(f"state_map: {json.dumps(state_map)}")
sha_history = []
updated_history = []
@ -73,7 +69,7 @@ def process_state(arch_state, history: list[Message]):
joined_key_str = ("#.#").join(sha_history)
sha256_hash.update(joined_key_str.encode())
sha_key = sha256_hash.hexdigest()
print(f"sha_key: {sha_key}")
logger.info(f"sha_key: {sha_key}")
if sha_key in state_map:
tool_call_state = state_map[sha_key]
if "tool_call" in tool_call_state: