(model, input)
| 24 | interval=20 |
| 25 | ) |
| 26 | def get_openai_embed(model, input): |
| 27 | openai.api_key = CONFIG['emb_api_key'] |
| 28 | openai.api_type = "azure" |
| 29 | openai.api_base = "https://gpt-jp-az.openai.azure.com/" |
| 30 | openai.api_version = "2023-05-15" |
| 31 | openai.debug = True |
| 32 | with requests.Session() as session: |
| 33 | openai.requestssession = session |
| 34 | try: |
| 35 | response = openai.Embedding.create( |
| 36 | engine=model, input=input) |
| 37 | result = [e['embedding'] for e in response['data']] |
| 38 | except Exception as e: |
| 39 | result = 'error:{}'.format(e) |
| 40 | print(result) |
| 41 | return result |
| 42 | |
| 43 | |
| 44 | if __name__ == '__main__': |
no outgoing calls
no test coverage detected