Raiff1982 commited on
Commit
b6ae3d6
·
verified ·
1 Parent(s): 9c9fc77

Update ai_core.py

Browse files
Files changed (1) hide show
  1. ai_core.py +22 -1
ai_core.py CHANGED
@@ -91,7 +91,8 @@ class AICoreFinalRecursive:
91
  return best_response
92
 
93
  def _evaluate_response_quality(self, response: str) -> float:
94
- return sum(ord(char) for char in response) % 100 / 100.0 # Simplified heuristic for refinement
 
95
 
96
  async def _generate_local_model_response(self, query: str) -> str:
97
  inputs = self.tokenizer(query, return_tensors="pt")
@@ -101,3 +102,23 @@ class AICoreFinalRecursive:
101
  def _speak_response(self, response: str):
102
  self.speech_engine.say(response)
103
  self.speech_engine.runAndWait()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
91
  return best_response
92
 
93
  def _evaluate_response_quality(self, response: str) -> float:
94
+ # Simplified heuristic for refinement
95
+ return sum(ord(char) for char in response) % 100 / 100.0
96
 
97
  async def _generate_local_model_response(self, query: str) -> str:
98
  inputs = self.tokenizer(query, return_tensors="pt")
 
102
  def _speak_response(self, response: str):
103
  self.speech_engine.say(response)
104
  self.speech_engine.runAndWait()
105
+
106
+ # Main function to initialize and run the AI Core
107
+ async def main():
108
+ try:
109
+ logging.info("Initializing AI Core...")
110
+ ai_core = AICoreFinalRecursive(config_path="config_updated.json")
111
+ query = "What is the latest in AI advancements?"
112
+ logging.info(f"Processing query: {query}")
113
+
114
+ response = await ai_core.generate_response(query, user_id=1)
115
+ logging.info("Response received successfully.")
116
+ print("AI Response:", response)
117
+
118
+ await ai_core.http_session.close()
119
+ logging.info("Closed AI Core session.")
120
+ except Exception as e:
121
+ logging.error(f"An error occurred: {e}")
122
+
123
+ if __name__ == "__main__":
124
+ asyncio.run(main())