Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix workspace not found bug: version issue #95

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions search_with_lepton.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import os
import re
import threading
import leptonai.api
import requests
import traceback
from typing import Annotated, List, Generator, Optional
Expand All @@ -18,7 +19,6 @@
from leptonai.kv import KV
from leptonai.photon import Photon, StaticFiles
from leptonai.photon.types import to_bool
from leptonai.api.workspace import WorkspaceInfoLocalRecord
from leptonai.util import tool

################################################################################
Expand Down Expand Up @@ -366,8 +366,7 @@ def local_client(self):
except AttributeError:
thread_local.client = openai.OpenAI(
base_url=f"https://{self.model}.lepton.run/api/v1/",
api_key=os.environ.get("LEPTON_WORKSPACE_TOKEN")
or WorkspaceInfoLocalRecord.get_current_workspace_token(),
api_key=os.environ.get("LEPTON_WORKSPACE_TOKEN"),
# We will set the connect timeout to be 10 seconds, and read/write
# timeout to be 120 seconds, in case the inference server is
# overloaded.
Expand All @@ -380,13 +379,12 @@ def init(self):
Initializes photon configs.
"""
# First, log in to the workspace.
leptonai.api.workspace.login()
leptonai.api.v0.workspace.login()
self.backend = os.environ["BACKEND"].upper()
if self.backend == "LEPTON":
self.leptonsearch_client = Client(
"https://search-api.lepton.run/",
token=os.environ.get("LEPTON_WORKSPACE_TOKEN")
or WorkspaceInfoLocalRecord.get_current_workspace_token(),
token=os.environ.get("LEPTON_WORKSPACE_TOKEN"),
stream=True,
timeout=httpx.Timeout(connect=10, read=120, write=120, pool=10),
)
Expand Down