tuxedocat commited on
Commit
9e03ce7
1 Parent(s): ad59171
Files changed (2) hide show
  1. app.py +2 -17
  2. const.py +4 -9
app.py CHANGED
@@ -1,30 +1,15 @@
1
  import base64
2
  import io
3
- import os
4
- import subprocess
5
  from functools import partial
6
 
7
  import gradio as gr
8
  import httpx
9
- from const import CLI_COMMAND, CSS, FOOTER, HEADER, MODELS, PLACEHOLDER
10
  from openai import OpenAI
11
  from PIL import Image
12
  from cycloud.auth import load_default_credentials
13
 
14
 
15
- def get_token() -> str:
16
- return (
17
- subprocess.run(
18
- CLI_COMMAND,
19
- stdout=subprocess.PIPE,
20
- stderr=subprocess.DEVNULL,
21
- env=os.environ.copy(),
22
- )
23
- .stdout.decode("utf-8")
24
- .strip()
25
- )
26
-
27
-
28
  def get_headers(host: str) -> dict:
29
  creds = load_default_credentials()
30
  return {
@@ -93,7 +78,7 @@ def call_chat_api(message, history, model_name):
93
 
94
  client = OpenAI(
95
  api_key="",
96
- base_url=MODELS[model_name]['host'],
97
  http_client=httpx.Client(
98
  event_hooks={
99
  "request": [partial(proxy, model_info=MODELS[model_name])],
 
1
  import base64
2
  import io
 
 
3
  from functools import partial
4
 
5
  import gradio as gr
6
  import httpx
7
+ from const import CSS, FOOTER, HEADER, MODELS, PLACEHOLDER
8
  from openai import OpenAI
9
  from PIL import Image
10
  from cycloud.auth import load_default_credentials
11
 
12
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
  def get_headers(host: str) -> dict:
14
  creds = load_default_credentials()
15
  return {
 
78
 
79
  client = OpenAI(
80
  api_key="",
81
+ base_url=MODELS[model_name]["host"],
82
  http_client=httpx.Client(
83
  event_hooks={
84
  "request": [partial(proxy, model_info=MODELS[model_name])],
const.py CHANGED
@@ -9,16 +9,11 @@ os.environ[SECRET_PREFIX + "PROJECT_ID"] = PROJECT_ID
9
  os.environ[SECRET_PREFIX + "ROLE_SUBJECT"] = ROLE_SUBJECT
10
  os.environ[SECRET_PREFIX + "CREDENTIALS"] = CREDENTIALS
11
 
12
- BASE_HOST = os.environ.get("GCLOUD_HOST", "")
13
- BASE_ENDPOINT = os.environ.get("GCLOUD_ENDPOINT", "")
14
- CHATTY_HOST = os.environ.get("GCLOUD_CHATTY_HOST", "")
15
- CHATTY_ENDPOINT = os.environ.get("GCLOUD_CHATTY_ENDPOINT", "")
16
- CLI_COMMAND_NAME = os.environ.get("CLI_COMMAND_NAME", "")
17
- CLI_ARG1 = os.environ.get("CLI_ARG1", "")
18
- CLI_ARG2 = os.environ.get("CLI_ARG2", "")
19
  ROOT_DIR = Path(__file__).parent.absolute()
20
- GCLOUD_BIN = str(ROOT_DIR / CLI_COMMAND_NAME)
21
- CLI_COMMAND = [GCLOUD_BIN, CLI_ARG1, CLI_ARG2]
22
 
23
  MODELS = {
24
  "llava-calm2-siglip-chatty": {"host": CHATTY_HOST, "endpoint": CHATTY_ENDPOINT},
 
9
  os.environ[SECRET_PREFIX + "ROLE_SUBJECT"] = ROLE_SUBJECT
10
  os.environ[SECRET_PREFIX + "CREDENTIALS"] = CREDENTIALS
11
 
12
+ BASE_HOST = os.environ.get("BASE_HOST", "")
13
+ BASE_ENDPOINT = os.environ.get("BASE_ENDPOINT", "")
14
+ CHATTY_HOST = os.environ.get("CHATTY_HOST", "")
15
+ CHATTY_ENDPOINT = os.environ.get("CHATTY_ENDPOINT", "")
 
 
 
16
  ROOT_DIR = Path(__file__).parent.absolute()
 
 
17
 
18
  MODELS = {
19
  "llava-calm2-siglip-chatty": {"host": CHATTY_HOST, "endpoint": CHATTY_ENDPOINT},