neue version
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
.env
|
||||
@@ -1,9 +1,7 @@
|
||||
import os
|
||||
import openai
|
||||
from openai import OpenAI
|
||||
from tkinter import simpledialog, Tk, Label, Entry, Button, Text, filedialog
|
||||
|
||||
# Set your OpenAI API key here
|
||||
openai.api_key = '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'
|
||||
from dotenv import load_dotenv
|
||||
|
||||
def get_user_input():
|
||||
root = None # No parent window for simplicity
|
||||
@@ -21,18 +19,20 @@ def list_files(directory):
|
||||
return files
|
||||
|
||||
def compare_with_openai(content, search_query):
|
||||
response = openai.Completion.create(
|
||||
engine="text-davinci-003",
|
||||
prompt=f"Vergleiche den folgenden Text mit der Suchanfrage '{search_query}':\n\n{content[:1000]}...\n\nIst der Text relevant für die Suchanfrage?",
|
||||
max_tokens=50,
|
||||
n=1,
|
||||
stop=None,
|
||||
temperature=0.5,
|
||||
client = OpenAI(
|
||||
api_key=os.environ.get("OPENAI_API_KEY")
|
||||
)
|
||||
return "ja" in response.choices[0].text.lower()
|
||||
|
||||
chat_completion = client.chat.completions.create(
|
||||
messages=[
|
||||
{
|
||||
"role": "user",
|
||||
"content": f"Vergleiche den folgenden Text mit der Suchanfrage '{search_query}':\n\n{content[:1000]}...\n\nIst der Text relevant für die Suchanfrage?"},
|
||||
],
|
||||
model="gpt-4o-mini",
|
||||
)
|
||||
return "ja" in chat_completion.choices[0].message.content.lower()
|
||||
def search_files():
|
||||
search_query = get_user_input()
|
||||
search_query = query_entry.get() # Get the search query from the Entry widget
|
||||
if not search_query:
|
||||
print("No search query provided.")
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user