AJ-Gazin commited on
Commit
9d582af
2 Parent(s): 7666783 40ef43a

added api access token

Browse files
Files changed (3) hide show
  1. .gitignore +2 -1
  2. app.py +5 -3
  3. requirements.txt +1 -1
.gitignore CHANGED
@@ -1 +1,2 @@
1
- /myvenv
 
 
1
+ /myvenv
2
+ .env
app.py CHANGED
@@ -1,16 +1,18 @@
1
  import gradio as gr
2
  from openai import OpenAI, APIConnectionError, BadRequestError
3
  from gradio_client import Client
 
4
 
5
  # Define the client to interact with the original Gradio app for prompt customization
6
- client = Client("neuronslabs/Text_modulator")
 
7
 
8
  SYSTEM_PROMPT = """You are an advanced multilingual text transformation AI. Your role is to transform the provided text based on specific tasks, ensuring the core meaning remains intact. Each transformation should be distinct, creative, and suitable for the intended audience. Generate exactly 3 distinct variations of the transformed text, separated by '---'. Pay attention to language nuances, style, and context to enhance clarity and engagement."""
9
 
10
  def validate_api_key(api_key):
11
  try:
12
- client = OpenAI(api_key=api_key)
13
- client.models.list()
14
  return True
15
  except Exception:
16
  return False
 
1
  import gradio as gr
2
  from openai import OpenAI, APIConnectionError, BadRequestError
3
  from gradio_client import Client
4
+ import os
5
 
6
  # Define the client to interact with the original Gradio app for prompt customization
7
+ access_token = os.getenv('PRIVATE_ACCESS_KEY') # Replace with your actual access token
8
+ client = Client("neuronslabs/Text_modulator", hf_token=access_token)
9
 
10
  SYSTEM_PROMPT = """You are an advanced multilingual text transformation AI. Your role is to transform the provided text based on specific tasks, ensuring the core meaning remains intact. Each transformation should be distinct, creative, and suitable for the intended audience. Generate exactly 3 distinct variations of the transformed text, separated by '---'. Pay attention to language nuances, style, and context to enhance clarity and engagement."""
11
 
12
  def validate_api_key(api_key):
13
  try:
14
+ openai_client = OpenAI(api_key=api_key)
15
+ openai_client.models.list()
16
  return True
17
  except Exception:
18
  return False
requirements.txt CHANGED
@@ -1 +1 @@
1
- openai
 
1
+ openai==1.31.2