app1
Browse files
app.py
CHANGED
|
@@ -1,47 +1,3 @@
|
|
| 1 |
-
# import os
|
| 2 |
-
# from dotenv import load_dotenv
|
| 3 |
-
# load_dotenv()
|
| 4 |
-
# import openai
|
| 5 |
-
# import gradio
|
| 6 |
-
|
| 7 |
-
# openai.api_key = os.getenv("OPENAI_API_KEY")
|
| 8 |
-
|
| 9 |
-
# messages = [
|
| 10 |
-
# {"role": "system", "content": "You are a Competitive Programming expert that specializes in coding and Competitive Data structures and Algorithms"}
|
| 11 |
-
# ]
|
| 12 |
-
|
| 13 |
-
# def count_tokens(messages):
|
| 14 |
-
# total_tokens = 0
|
| 15 |
-
# for message in messages:
|
| 16 |
-
# content = message.get("content", "")
|
| 17 |
-
# tokens = len(content.split())
|
| 18 |
-
# total_tokens += tokens
|
| 19 |
-
# return total_tokens
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
# def truncate_messages(messages, max_tokens):
|
| 24 |
-
# while count_tokens(messages) > max_tokens:
|
| 25 |
-
# messages.pop(0)
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
# def CustomChatGPT(user_input):
|
| 30 |
-
# messages.append({"role": "user", "content": user_input})
|
| 31 |
-
# max_tokens = 4097 # Maximum token limit for GPT-3.5 Turbo model
|
| 32 |
-
# truncate_messages(messages, max_tokens)
|
| 33 |
-
# response = openai.ChatCompletion.create(model="gpt-3.5-turbo", messages=messages)
|
| 34 |
-
# ChatGPT_reply = response["choices"][0]["message"]["content"]
|
| 35 |
-
# messages.append({"role": "assistant", "content": ChatGPT_reply})
|
| 36 |
-
|
| 37 |
-
# return ChatGPT_reply
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
# demo = gradio.Interface(fn=CustomChatGPT, inputs="text", outputs="text", title="CodeGPT",description="CodeGPT is a GPT-3.5 Turbo-based coding assistant for general programming jobs, data structures, algorithms, and competitive programming. You can extract text responses to coding-related prompts using this model.Using OpenAI's potent GPT-3.5 Turbo model, CodeGPT was created. We would like to thank OpenAI for their contributions to the machine learning and natural language processing fields.")
|
| 41 |
-
|
| 42 |
-
# demo.launch()
|
| 43 |
-
|
| 44 |
-
|
| 45 |
import os
|
| 46 |
from dotenv import load_dotenv
|
| 47 |
load_dotenv()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import os
|
| 2 |
from dotenv import load_dotenv
|
| 3 |
load_dotenv()
|