Reformat
This commit is contained in:
@@ -1,8 +1,10 @@
|
|||||||
#! /usr/bin/env python3
|
#! /usr/bin/env python3
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import google.generativeai as genai
|
import google.generativeai as genai
|
||||||
|
|
||||||
|
|
||||||
class BardAssistant:
|
class BardAssistant:
|
||||||
def __init__(self, conf: dict) -> None:
|
def __init__(self, conf: dict) -> None:
|
||||||
self._api_key = conf["api_key"]
|
self._api_key = conf["api_key"]
|
||||||
@@ -13,7 +15,6 @@ class BardAssistant:
|
|||||||
genai.configure(api_key=self._api_key)
|
genai.configure(api_key=self._api_key)
|
||||||
self._bard = genai.GenerativeModel(self._model_name)
|
self._bard = genai.GenerativeModel(self._model_name)
|
||||||
|
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return 'BardAssistant'
|
return 'BardAssistant'
|
||||||
|
|
||||||
@@ -25,17 +26,16 @@ class BardAssistant:
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
def get_answer(self, msg: str, sender: str = None) -> str:
|
def get_answer(self, msg: str, sender: str = None) -> str:
|
||||||
response = self._bard.generate_content([{'role': 'user',
|
response = self._bard.generate_content([{'role': 'user', 'parts': [msg]}])
|
||||||
'parts':[msg]}])
|
|
||||||
return response.text
|
return response.text
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
from configuration import Config
|
from configuration import Config
|
||||||
config = Config().BardAssistant
|
config = Config().BardAssistant
|
||||||
if not config:
|
if not config:
|
||||||
exit(0)
|
exit(0)
|
||||||
|
|
||||||
|
|
||||||
bard_assistant = BardAssistant(config)
|
bard_assistant = BardAssistant(config)
|
||||||
if bard_assistant._proxy:
|
if bard_assistant._proxy:
|
||||||
os.environ['HTTP_PROXY'] = bard_assistant._proxy
|
os.environ['HTTP_PROXY'] = bard_assistant._proxy
|
||||||
|
|||||||
Reference in New Issue
Block a user