Added .gitignore
Browse files
whatif.py
CHANGED
@@ -3,14 +3,12 @@ import os
|
|
3 |
from langchain.llms import OpenAI
|
4 |
from langchain.chat_models import ChatOpenAI
|
5 |
from langchain.schema import HumanMessage, SystemMessage, AIMessage
|
6 |
-
from dotenv import load_dotenv
|
7 |
|
8 |
-
load_dotenv("E:/Development/Python/scripts/keys.env")
|
9 |
openai_key = os.getenv("OPENAI_API_KEY")
|
10 |
print(openai_key)
|
11 |
-
|
12 |
-
# print(os.getenv.__doc__)
|
13 |
-
# print(llm("Love is in the air"))
|
14 |
|
15 |
chat1 = ChatOpenAI(temperature=0.9, openai_api_key=openai_key)
|
16 |
chat2 = ChatOpenAI(temperature=0.9, openai_api_key=openai_key)
|
@@ -23,15 +21,26 @@ def format_chat(chat_history):
|
|
23 |
return chat_html
|
24 |
|
25 |
def color_chg(name):
|
26 |
-
|
27 |
-
|
28 |
|
29 |
-
|
30 |
-
red = (value %
|
31 |
-
green = (
|
32 |
-
blue = (
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
|
34 |
-
# Format the RGB values into a hex color string
|
35 |
color_hex = "#{:02x}{:02x}{:02x}".format(red, green, blue)
|
36 |
return color_hex
|
37 |
|
@@ -74,8 +83,8 @@ def initialize(name1, name2, iterations):
|
|
74 |
response2 = chat2(MessageStack2)
|
75 |
print(name2+": "+response2.content)
|
76 |
MsgStack.append( name2+": "+response2.content)
|
77 |
-
chat_history.append({"sender": name1, "content": response1.content, "color" :
|
78 |
-
chat_history.append({"sender": name2, "content": response2.content, "color" :
|
79 |
|
80 |
|
81 |
# MessageStack1.append(HumanMessage(content = response2.content))
|
|
|
3 |
from langchain.llms import OpenAI
|
4 |
from langchain.chat_models import ChatOpenAI
|
5 |
from langchain.schema import HumanMessage, SystemMessage, AIMessage
|
6 |
+
# from dotenv import load_dotenv
|
7 |
|
8 |
+
# load_dotenv("E:/Development/Python/scripts/keys.env")
|
9 |
openai_key = os.getenv("OPENAI_API_KEY")
|
10 |
print(openai_key)
|
11 |
+
|
|
|
|
|
12 |
|
13 |
chat1 = ChatOpenAI(temperature=0.9, openai_api_key=openai_key)
|
14 |
chat2 = ChatOpenAI(temperature=0.9, openai_api_key=openai_key)
|
|
|
21 |
return chat_html
|
22 |
|
23 |
def color_chg(name):
|
24 |
+
background_color = (11, 15, 25)
|
25 |
+
background_brightness = sum(background_color) / len(background_color)
|
26 |
|
27 |
+
value = sum(ord(char) for char in name)
|
28 |
+
red = (value % 128) + 128
|
29 |
+
green = (value // 128 % 128) + 128
|
30 |
+
blue = (value // 16384 % 128) + 128
|
31 |
+
|
32 |
+
# Calculate the contrast ratio between the background and the generated color
|
33 |
+
brightness = (red + green + blue) / 3
|
34 |
+
contrast_ratio = max(brightness, background_brightness) / min(brightness, background_brightness)
|
35 |
+
|
36 |
+
# Adjust the brightness of the generated color if the contrast ratio is too low
|
37 |
+
if contrast_ratio < 4.5:
|
38 |
+
# Increase the brightness by finding the ratio needed to achieve the desired contrast ratio
|
39 |
+
brightness_ratio = 4.5 / contrast_ratio
|
40 |
+
red = min(int(red * brightness_ratio), 255)
|
41 |
+
green = min(int(green * brightness_ratio), 255)
|
42 |
+
blue = min(int(blue * brightness_ratio), 255)
|
43 |
|
|
|
44 |
color_hex = "#{:02x}{:02x}{:02x}".format(red, green, blue)
|
45 |
return color_hex
|
46 |
|
|
|
83 |
response2 = chat2(MessageStack2)
|
84 |
print(name2+": "+response2.content)
|
85 |
MsgStack.append( name2+": "+response2.content)
|
86 |
+
chat_history.append({"sender": name1, "content": response1.content, "color" : color_chg(name1) } )
|
87 |
+
chat_history.append({"sender": name2, "content": response2.content, "color" : color_chg(name2) } )
|
88 |
|
89 |
|
90 |
# MessageStack1.append(HumanMessage(content = response2.content))
|