73
73
from pyqt_openai .globals import (
74
74
DB ,
75
75
OPENAI_CLIENT ,
76
- ANTHROPIC_CLIENT ,
77
76
G4F_CLIENT ,
78
77
LLAMAINDEX_WRAPPER ,
79
78
REPLICATE_CLIENT ,
@@ -718,13 +717,10 @@ def get_claude_argument(model, system, messages, cur_text, stream, images):
718
717
def set_api_key (env_var_name , api_key ):
719
718
api_key = api_key .strip () if api_key else ""
720
719
if env_var_name == "OPENAI_API_KEY" :
721
- OPENAI_CLIENT .api_key = api_key
722
720
os .environ ["OPENAI_API_KEY" ] = api_key
723
721
if env_var_name == "GEMINI_API_KEY" :
724
- genai .configure (api_key = api_key )
725
722
os .environ ["GEMINI_API_KEY" ] = api_key
726
723
if env_var_name == "CLAUDE_API_KEY" :
727
- ANTHROPIC_CLIENT .api_key = api_key
728
724
os .environ ["ANTHROPIC_API_KEY" ] = api_key
729
725
if env_var_name == "REPLICATE_API_KEY" :
730
726
REPLICATE_CLIENT .api_key = api_key
@@ -898,36 +894,23 @@ def get_api_argument(
898
894
json_content = None ,
899
895
):
900
896
try :
901
- provider = get_provider_from_model (model )
902
- if provider == "OpenAI" :
903
- args = get_gpt_argument (
904
- model ,
905
- system ,
906
- messages ,
907
- cur_text ,
908
- temperature ,
909
- top_p ,
910
- frequency_penalty ,
911
- presence_penalty ,
912
- stream ,
913
- use_max_tokens ,
914
- max_tokens ,
915
- images ,
916
- is_llama_available = is_llama_available ,
917
- is_json_response_available = is_json_response_available ,
918
- json_content = json_content ,
919
- )
920
- elif provider == "Gemini" :
921
- args = get_gemini_argument (
922
- model , system , messages , cur_text , stream , images
923
- )
924
-
925
- elif provider == "Anthropic" :
926
- args = get_claude_argument (
927
- model , system , messages , cur_text , stream , images
928
- )
929
- else :
930
- raise Exception (f"Provider not found for model { model } " )
897
+ args = get_gpt_argument (
898
+ model ,
899
+ system ,
900
+ messages ,
901
+ cur_text ,
902
+ temperature ,
903
+ top_p ,
904
+ frequency_penalty ,
905
+ presence_penalty ,
906
+ stream ,
907
+ use_max_tokens ,
908
+ max_tokens ,
909
+ images ,
910
+ is_llama_available = is_llama_available ,
911
+ is_json_response_available = is_json_response_available ,
912
+ json_content = json_content ,
913
+ )
931
914
return args
932
915
except Exception as e :
933
916
print (e )
@@ -979,7 +962,7 @@ def get_argument(
979
962
raise e
980
963
981
964
982
- def stream_response (provider , response , is_g4f = False , get_content_only = True ):
965
+ def stream_response (response , is_g4f = False , get_content_only = True ):
983
966
if is_g4f :
984
967
if get_content_only :
985
968
for chunk in response :
@@ -994,10 +977,10 @@ def stream_response(provider, response, is_g4f=False, get_content_only=True):
994
977
995
978
def get_api_response (args , get_content_only = True ):
996
979
try :
997
- provider = get_provider_from_model (args [ "model" ] )
980
+ print (args )
998
981
response = completion (drop_params = True , ** args )
999
982
if args ["stream" ]:
1000
- return stream_response (provider , response )
983
+ return stream_response (response )
1001
984
else :
1002
985
return response .choices [0 ].message .content or ""
1003
986
except Exception as e :
@@ -1010,7 +993,6 @@ def get_g4f_response(args, get_content_only=True):
1010
993
response = G4F_CLIENT .chat .completions .create (** args )
1011
994
if args ["stream" ]:
1012
995
return stream_response (
1013
- provider = "" ,
1014
996
response = response ,
1015
997
is_g4f = True ,
1016
998
get_content_only = get_content_only ,
@@ -1174,8 +1156,7 @@ class RecorderThread(QThread):
1174
1156
recording_finished = Signal (str )
1175
1157
errorGenerated = Signal (str )
1176
1158
1177
- # Silence detection 사용 여부
1178
-
1159
+ # Silence detection parameters
1179
1160
def __init__ (
1180
1161
self , is_silence_detection = False , silence_duration = 3 , silence_threshold = 500
1181
1162
):
0 commit comments