Skip to content

Commit

Permalink
Merge pull request #12617 from Avishka-Shamendra/ai-api-bug-fixes
Browse files Browse the repository at this point in the history
[Bug Fix] Fix AI API DB Script Issues
  • Loading branch information
RakhithaRR authored Oct 2, 2024
2 parents 3c0918b + 5744f91 commit da15011
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14653,8 +14653,10 @@ public LLMProvider addLLMProvider(LLMProvider provider) throws APIManagementExce
prepStmt.setString(4, String.valueOf(provider.isBuiltInSupport()));
prepStmt.setString(5, provider.getOrganization());
prepStmt.setString(6, provider.getDescription());
prepStmt.setString(7, provider.getApiDefinition());
prepStmt.setString(8, provider.getConfigurations());
prepStmt.setBinaryStream(7, new ByteArrayInputStream(provider
.getApiDefinition().getBytes()));
prepStmt.setBinaryStream(8, new ByteArrayInputStream(provider
.getConfigurations().getBytes()));
int rowsAffected = prepStmt.executeUpdate();
if (rowsAffected > 0) {
conn.commit();
Expand Down Expand Up @@ -14699,7 +14701,13 @@ public List<LLMProvider> getLLMProviders(String organization, String name, Strin
provider.setOrganization(resultSet.getString("ORGANIZATION"));
provider.setBuiltInSupport(Boolean.parseBoolean(resultSet.getString("BUILT_IN_SUPPORT")));
provider.setDescription(resultSet.getString("DESCRIPTION"));
provider.setConfigurations(resultSet.getString("CONFIGURATIONS"));
try (InputStream configStream = resultSet.getBinaryStream("CONFIGURATIONS")) {
if (configStream != null) {
provider.setConfigurations(IOUtils.toString(configStream));
}
} catch (IOException e) {
log.error("Error while retrieving LLM configuration", e);
}
providerList.add(provider);
}
}
Expand Down Expand Up @@ -14934,8 +14942,20 @@ public LLMProvider getLLMProvider(String organization, String llmProviderId) thr
provider.setApiVersion(resultSet.getString("API_VERSION"));
provider.setBuiltInSupport(Boolean.parseBoolean(resultSet.getString("BUILT_IN_SUPPORT")));
provider.setDescription(resultSet.getString("DESCRIPTION"));
provider.setApiDefinition(resultSet.getString("API_DEFINITION"));
provider.setConfigurations(resultSet.getString("CONFIGURATIONS"));
try (InputStream apiDefStream = resultSet.getBinaryStream("API_DEFINITION")) {
if (apiDefStream != null) {
provider.setApiDefinition(IOUtils.toString(apiDefStream));
}
} catch (IOException e) {
log.error("Error while retrieving LLM API definition", e);
}
try (InputStream configStream = resultSet.getBinaryStream("CONFIGURATIONS")) {
if (configStream != null) {
provider.setConfigurations(IOUtils.toString(configStream));
}
} catch (IOException e) {
log.error("Error while retrieving LLM configuration", e);
}
return provider;

} catch (SQLException e) {
Expand All @@ -14962,8 +14982,20 @@ public LLMProvider getLLMProvider(String organization, String name, String apiVe
provider.setApiVersion(resultSet.getString("API_VERSION"));
provider.setBuiltInSupport(Boolean.parseBoolean(resultSet.getString("BUILT_IN_SUPPORT")));
provider.setDescription(resultSet.getString("DESCRIPTION"));
provider.setApiDefinition(resultSet.getString("API_DEFINITION"));
provider.setConfigurations(resultSet.getString("CONFIGURATIONS"));
try (InputStream apiDefStream = resultSet.getBinaryStream("API_DEFINITION")) {
if (apiDefStream != null) {
provider.setApiDefinition(IOUtils.toString(apiDefStream));
}
} catch (IOException e) {
log.error("Error while retrieving LLM API definition", e);
}
try (InputStream configStream = resultSet.getBinaryStream("CONFIGURATIONS")) {
if (configStream != null) {
provider.setConfigurations(IOUtils.toString(configStream));
}
} catch (IOException e) {
log.error("Error while retrieving LLM configuration", e);
}
return provider;

} catch (SQLException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2757,7 +2757,7 @@ IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[A
CREATE TABLE AM_API_AI_CONFIGURATION (
AI_CONFIGURATION_UUID VARCHAR(255) NOT NULL,
API_UUID VARCHAR(256) NOT NULL,
API_REVISION_UUID VARCHAR(255) NOT NULL,
API_REVISION_UUID VARCHAR(255),
LLM_PROVIDER_UUID VARCHAR(255) NOT NULL,
ENDPOINT_CONFIGURATION VARCHAR(2048) NOT NULL,
THROTTLING_CONFIGURATIONS VARCHAR(1024) NOT NULL,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3871,7 +3871,7 @@ CREATE TABLE AM_LLM_PROVIDER (
CREATE TABLE AM_API_AI_CONFIGURATION (
AI_CONFIGURATION_UUID VARCHAR(255) NOT NULL,
API_UUID VARCHAR(256) NOT NULL,
API_REVISION_UUID VARCHAR(255) NOT NULL,
API_REVISION_UUID VARCHAR(255),
LLM_PROVIDER_UUID VARCHAR(255) NOT NULL,
ENDPOINT_CONFIGURATION VARCHAR(2048) NOT NULL,
THROTTLING_CONFIGURATIONS VARCHAR(1024) NOT NULL,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3871,7 +3871,7 @@ CREATE TABLE AM_LLM_PROVIDER (
CREATE TABLE AM_API_AI_CONFIGURATION (
AI_CONFIGURATION_UUID VARCHAR(255) NOT NULL,
API_UUID VARCHAR(256) NOT NULL,
API_REVISION_UUID VARCHAR(255) NOT NULL,
API_REVISION_UUID VARCHAR(255),
LLM_PROVIDER_UUID VARCHAR(255) NOT NULL,
ENDPOINT_CONFIGURATION VARCHAR(2048) NOT NULL,
THROTTLING_CONFIGURATIONS VARCHAR(1024) NOT NULL,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3842,7 +3842,7 @@ CREATE TABLE AM_LLM_PROVIDER (
CREATE TABLE AM_API_AI_CONFIGURATION (
AI_CONFIGURATION_UUID VARCHAR(255) NOT NULL,
API_UUID VARCHAR(256) NOT NULL,
API_REVISION_UUID VARCHAR(255) NOT NULL,
API_REVISION_UUID VARCHAR(255),
LLM_PROVIDER_UUID VARCHAR(255) NOT NULL,
ENDPOINT_CONFIGURATION VARCHAR(2048) NOT NULL,
THROTTLING_CONFIGURATIONS VARCHAR(1024) NOT NULL,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2858,7 +2858,7 @@ DROP TABLE IF EXISTS AM_API_AI_CONFIGURATION;
CREATE TABLE IF NOT EXISTS AM_API_AI_CONFIGURATION (
AI_CONFIGURATION_UUID VARCHAR(255) NOT NULL,
API_UUID VARCHAR(256) NOT NULL,
API_REVISION_UUID VARCHAR(255) NOT NULL,
API_REVISION_UUID VARCHAR(255),
LLM_PROVIDER_UUID VARCHAR(255) NOT NULL,
ENDPOINT_CONFIGURATION VARCHAR(2048) NOT NULL,
THROTTLING_CONFIGURATIONS VARCHAR(1024) NOT NULL,
Expand Down

0 comments on commit da15011

Please sign in to comment.