Skip to content

Commit

Permalink
Moving logic to single location
Browse files Browse the repository at this point in the history
  • Loading branch information
kylebunting committed Jul 30, 2024
1 parent 770cb4a commit 0c76f20
Showing 1 changed file with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ def __init__(self, config: Configuration):
# Retrieve the State API configuration settings.
self.state_api_url = config.get_value('FoundationaLLM:APIEndpoints:StateAPI:APIUrl').rstrip('/')
self.state_api_key = config.get_value('FoundationaLLM:APIEndpoints:StateAPI:APIKey')
self.env = os.environ.get('FOUNDATIONALLM_ENV', 'prod')
env = os.environ.get('FOUNDATIONALLM_ENV', 'prod')
self.verify_certs = False if env == 'dev' else True

async def create_operation(
self,
Expand Down Expand Up @@ -53,7 +54,7 @@ async def create_operation(
r = requests.post(
f'{self.state_api_url}/instances/{instance_id}/operations/{operation_id}',
headers=headers,
verify=False if self.env == 'dev' else True
verify=self.verify_certs
)

if r.status_code != 200:
Expand Down Expand Up @@ -107,7 +108,7 @@ async def update_operation(self,
f'{self.state_api_url}/instances/{instance_id}/operations/{operation_id}',
json=operation.model_dump(exclude_unset=True),
headers=headers,
verify=False if self.env == 'dev' else True
verify=self.verify_certs
)

if r.status_code == 404:
Expand Down Expand Up @@ -154,7 +155,7 @@ async def get_operation(
r = requests.get(
f'{self.state_api_url}/instances/{instance_id}/operations/{operation_id}',
headers=headers,
verify=False if self.env == 'dev' else True
verify=self.verify_certs
)

if r.status_code == 404:
Expand Down Expand Up @@ -198,7 +199,7 @@ async def set_operation_result(
f'{self.state_api_url}/instances/{instance_id}/operations/{operation_id}/result',
json=completion_response.model_dump(),
headers=headers,
verify=False if self.env == 'dev' else True
verify=self.verify_certs
)

if r.status_code == 404:
Expand Down Expand Up @@ -242,7 +243,7 @@ async def get_operation_result(
r = requests.get(
f'{self.state_api_url}/instances/{instance_id}/operations/{operation_id}/result',
headers=headers,
verify=False if self.env == 'dev' else True
verify=self.verify_certs
)

if r.status_code == 404:
Expand Down Expand Up @@ -287,7 +288,7 @@ async def get_operation_log(
r = requests.get(
f'{self.state_api_url}/instances/{instance_id}/operations/{operation_id}/logs',
headers=headers,
verify=False if self.env == 'dev' else True
verify=self.verify_certs
)

if r.status_code == 404:
Expand Down

0 comments on commit 0c76f20

Please sign in to comment.