Skip to content

Commit

Permalink
+ zrok setup to readme
Browse files Browse the repository at this point in the history
  • Loading branch information
jonnyjohnson1 committed May 29, 2024
1 parent 6aa3269 commit 1de33a4
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 39 deletions.
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,19 @@ Use the tag like this.
### Step 3: Start Topos on your local machine

`topos run`
`topos run --local`
`topos run --local`

### Step 4a (zrok): Set up web proxy
We are going to expose our backend service to a public network so our phone/tablet can use it. In this case, we use zrok. Below, is an ngrok setup version.
zrok is opensourced and free.
ngrok has a gated requests/month under its free tier, then requires you pay for it.

1. [Install zrok command](https://docs.zrok.io/docs/getting-started/?_gl=1*1yet1eb*_ga*MTQ1MDc2ODAyNi4xNzE3MDE3MTE3*_ga_V2KMEXWJ10*MTcxNzAxNzExNi4xLjAuMTcxNzAxNzExNi42MC4wLjA.*_gcl_au*NDk3NjM1MzEyLjE3MTcwMTcxMTc.#installing-the-zrok-command)
2. `zrok enable <given_key>`
3. `zrok status` should show you information
4. Route local path through zrok: `zrok share public http://0.0.0.0:13341`
This will take you to a new screen with an https://<url> at the top.
Insert this url into the field under settings-> "Api Endpoints" -> "Custom API"
5. After you've insert it into the field, press the test button, and "hello world" should appear next to the button.

### Step 4b (ngrok): Set up web proxy
4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "topos"
version = "0.1"
version = "0.2.1"
description = "The official Python client for Topos."
authors = ["Dialogues <[email protected]>"]
license = "MIT"
Expand All @@ -22,6 +22,8 @@ diffusers = "0.27.2"
accelerate = "0.30.1"
emoji = "0.6.0"
pyyaml = "6.0.1"
python-dotenv = "1.0.0"
openai = "1.30.4"

[tool.poetry.group.dev.dependencies]
pytest = "^7.4.3"
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = topos
version = 0.1
version = 0.2.1
author = Jonny Johnson
author_email = [email protected]
description = For interacting with Topos tooling
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name='topos',
version='0.1',
version='0.2.1',
packages=find_packages(),
entry_points={
'console_scripts': [
Expand Down
Binary file modified topos/.DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion topos/api/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

def start_local_api():
"""Function to start the API in local mode."""
print("\033[92mINFO:\033[0m API docs available at: http://0.0.0.0:13341/docs")
print("\033[92mINFO:\033[0m API docs available at: \033[1mhttp://0.0.0.0:13341/docs\033[0m")
uvicorn.run(app, host="0.0.0.0", port=13341)


Expand Down
37 changes: 4 additions & 33 deletions topos/api/api_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,44 +193,12 @@ async def create_next_messages(request: GenNextMessageOptions):
return {"response" : next_message_options}



class ConversationSummaryRequest(BaseModel):
conversation_id: str
subject: str
model: str

# @router.post("/gen_conversation_summary")
# async def create_next_messages(request: ConversationSummaryRequest):
# conversation_id = request.conversation_id
# subject = request.subject
# model = request.model if request.model != None else "dolphin-llama3"

# # load conversation
# conv_data = cache_manager.load_from_cache(conversation_id)
# if conv_data is None:
# raise HTTPException(status_code=404, detail="Conversation not found in cache")

# context = create_conversation_string(conv_data, 12)
# print(f"\t[ generating summary :: model {model} :: subject {subject}]")

# system_prompt = "PRESENT CONVERSATION:\n-------<context>" + context + "\n-------\n"
# query = f"""Summarize this conversation. Frame your response around the subject of {subject}
# """

# summarized_conversation = generate_response(system_prompt, query, model=model, temperature=0)
# print(summarized_conversation)

# # return the summary
# return {"response" : summarized_conversation}



class ConversationTopicsRequest(BaseModel):
conversation_id: str
model: str

@router.post("/gen_conversation_topics")
async def create_next_messages(request: ConversationSummaryRequest):
async def create_next_messages(request: ConversationTopicsRequest):
conversation_id = request.conversation_id
model = request.model if request.model != None else "dolphin-llama3"

Expand Down Expand Up @@ -264,6 +232,9 @@ async def list_models():
except requests.ConnectionError:
raise HTTPException(status_code=500, detail="Server connection error")

@router.post("/test")
async def test():
return "hello world"

@router.post("/get_files")
async def get_files():
Expand Down
2 changes: 1 addition & 1 deletion topos/downloaders/spacy_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def download_spacy_model(model_selection):
else: #default
model_name = "en_core_web_sm"
try:
subprocess.run(['python', '-m', 'spacy', 'download', model_name], check=True)
subprocess.run(['python3', '-m', 'spacy', 'download', model_name], check=True)
# Write updated settings to YAML file
with open('config.yaml', 'w') as file:
yaml.dump({'active_spacy_model': model_name}, file)
Expand Down

0 comments on commit 1de33a4

Please sign in to comment.