Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implementing a dotenv file #18

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,9 @@ This Artificially Assisted User Interface Testing framework is a pioneering tool
# Installation
```
# Add your Chat-GPT API Keys to the project:
add your API Key in /core/core_api.py -> line 3: client = OpenAI(api_key='insert_your_api_key_here')
add your API Key in /core/core_imaging.py -> line 12: api_key = 'insert_your_api_key_here'
Create a .env file with your API Key in the project folder
and add your key like this: OPENAI_API_KEY=sk-pr....


# Install requirements:
cd pywinassistant
Expand Down
9 changes: 7 additions & 2 deletions core/core_api.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import os
from dotenv import load_dotenv
from openai import OpenAI

client = OpenAI(api_key='insert_your_api_key_here')
load_dotenv()

openai_api_key = os.getenv('OPENAI_API_KEY')

client = OpenAI(api_key=openai_api_key)
# Available models: "gpt-4-1106-preview", "gpt-3.5-turbo-1106", or "davinci-codex"
MODEL_NAME = "gpt-3.5-turbo-1106"


def api_call(messages, model_name=MODEL_NAME, temperature=0.5, max_tokens=150):
# if model_name == "gpt-4-1106-preview":
# model_name = "gpt-3.5-turbo-1106"
Expand Down
6 changes: 4 additions & 2 deletions core/core_imaging.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@
import pygetwindow as gw
import base64
import requests
import os
import io
from PIL import Image
from dotenv import load_dotenv

# Assuming that the `activate_window_title` function is defined in another module correctly
from window_focus import activate_windowt_title

# OpenAI API Key
api_key = 'insert_your_api_key_here'
openai_api_key = os.getenv('OPENAI_API_KEY')


# Function to focus a window given its title
Expand Down Expand Up @@ -47,7 +49,7 @@ def analyze_image(base64_image, window_title, additional_context='What’s in th
# Your logic to call the OpenAI API
headers = {
"Content-Type": "application/json",
"Authorization": f"Bearer {api_key}"
"Authorization": f"Bearer {openai_api_key}"
}

payload = {
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ uiautomation
gtts
pygame
pyAudio
python-dotenv