John6666 commited on
Commit
a7c877f
1 Parent(s): addd508

Upload 2 files

Browse files
Files changed (2) hide show
  1. prompt.py +7 -2
  2. requirements.txt +2 -1
prompt.py CHANGED
@@ -14,6 +14,8 @@ import random
14
 
15
  subprocess.run('pip install flash-attn --no-build-isolation', env={'FLASH_ATTENTION_SKIP_CUDA_BUILD': "TRUE"}, shell=True)
16
 
 
 
17
  # Initialize Florence model
18
  device = "cuda" if torch.cuda.is_available() else "cpu"
19
  florence_model = AutoModelForCausalLM.from_pretrained('microsoft/Florence-2-base', trust_remote_code=True).to("cpu").eval()
@@ -318,11 +320,13 @@ class PromptGenerator:
318
  return prompt
319
 
320
  import os
 
321
 
322
  class HuggingFaceInferenceNode:
323
 
324
  def __init__(self):
325
- self.client = InferenceClient("meta-llama/Meta-Llama-3.1-70B-Instruct") #
 
326
  self.prompts_dir = "./prompts"
327
  os.makedirs(self.prompts_dir, exist_ok=True)
328
 
@@ -379,7 +383,8 @@ You are allowed to make up film and branding names, and do them like 80's, 90's
379
  {"role": "user", "content": user_message}
380
  ]
381
 
382
- response = self.client.chat_completion( #
 
383
  model="meta-llama/Meta-Llama-3.1-70B-Instruct",
384
  max_tokens=1024,
385
  temperature=0.7,
 
14
 
15
  subprocess.run('pip install flash-attn --no-build-isolation', env={'FLASH_ATTENTION_SKIP_CUDA_BUILD': "TRUE"}, shell=True)
16
 
17
+ huggingface_token = os.getenv("HF_TOKEN")
18
+
19
  # Initialize Florence model
20
  device = "cuda" if torch.cuda.is_available() else "cpu"
21
  florence_model = AutoModelForCausalLM.from_pretrained('microsoft/Florence-2-base', trust_remote_code=True).to("cpu").eval()
 
320
  return prompt
321
 
322
  import os
323
+ from openai import OpenAI
324
 
325
  class HuggingFaceInferenceNode:
326
 
327
  def __init__(self):
328
+ #self.client = InferenceClient("meta-llama/Meta-Llama-3.1-70B-Instruct") #
329
+ self.client = OpenAI(base_url="https://api-inference.huggingface.co/v1/", api_key=huggingface_token)
330
  self.prompts_dir = "./prompts"
331
  os.makedirs(self.prompts_dir, exist_ok=True)
332
 
 
383
  {"role": "user", "content": user_message}
384
  ]
385
 
386
+ #response = self.client.chat_completion( #
387
+ response = self.client.chat.completions.create(
388
  model="meta-llama/Meta-Llama-3.1-70B-Instruct",
389
  max_tokens=1024,
390
  temperature=0.7,
requirements.txt CHANGED
@@ -13,4 +13,5 @@ controlnet-aux
13
  kornia
14
  numpy
15
  opencv-python
16
- deepspeed
 
 
13
  kornia
14
  numpy
15
  opencv-python
16
+ deepspeed
17
+ openai==1.37.0