Skip to content

Commit

Permalink
Merge pull request #81 from ainize-team/fix/yoojin/request_type
Browse files Browse the repository at this point in the history
Fix request data type.
  • Loading branch information
yoojinko authored Dec 11, 2023
2 parents 6223b50 + e798c29 commit c6486b0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/controllers/serviceController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ export default class ServiceController {
return await 'information of service';
}

async calculateCost(serviceName: string, requestData: string): Promise<number> {
// FIXME(yoojin): Temporary deprecated. Need new pricing rules.
private async calculateCost(serviceName: string, requestData: string): Promise<number> {
const billingConfig = await this.ain.getValue(Path.app(serviceName).billingConfig());
const token = requestData.split(' ').length;
let cost = token * billingConfig.costPerToken;
Expand Down Expand Up @@ -71,7 +72,7 @@ export default class ServiceController {
return await this.ain.getValue(creditHistoryPath) as creditHistories;
}

async request(serviceName: string, requestData: string) : Promise<string> {
async request(serviceName: string, requestData: any) : Promise<any> {
this.isRunning(serviceName);
const result = await new Promise(async (resolve, reject) => {
const requestKey = Date.now();
Expand Down
6 changes: 4 additions & 2 deletions src/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ export default class Service {
* @returns {number} Estimated cost.
*/
async calculateCost (requestData: string) {
return await this.serviceController.calculateCost(this.serviceName, requestData);
// FIXME(yoojin): Temporary deprecated. Need new pricing rules.
// return await this.serviceController.calculateCost(this.serviceName, requestData);
return 0;
}

/**
Expand Down Expand Up @@ -76,7 +78,7 @@ export default class Service {
* @param {string} requestData String data for request to service.
* @returns {string} Response data from service.
*/
async request(requestData: string) {
async request(requestData: any) {
this.isLoggedIn();
return await this.serviceController.request(this.serviceName, requestData);
}
Expand Down

0 comments on commit c6486b0

Please sign in to comment.