Skip to content

Commit

Permalink
release(0.2.0): Release typescript-fetch SDK
Browse files Browse the repository at this point in the history
  • Loading branch information
kevin committed Jul 1, 2024
1 parent 7e2448e commit dd59117
Show file tree
Hide file tree
Showing 95 changed files with 991 additions and 86 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## @emergentmethods/asknews-typescript-sdk@0.1.14
## @emergentmethods/asknews-typescript-sdk@0.2.0

Typescript SDK for the AskNews API.
This SDK utilizes [Fetch API](https://fetch.spec.whatwg.org/). The generated Node module can be used in the following environments:
Expand All @@ -21,7 +21,7 @@ It can be used in both TypeScript and JavaScript. In TypeScript, the definition
### Installation

```
npm install @emergentmethods/asknews-typescript-sdk@0.1.14 --save
npm install @emergentmethods/asknews-typescript-sdk@0.2.0 --save
```

## Usage
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@emergentmethods/asknews-typescript-sdk",
"version": "0.1.14",
"version": "0.2.0",
"description": "Typescript SDK for AskNews API",
"author": "Emergent Methods <[email protected]>",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion src/apis/AnalyticsApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* AskNews API
* AskNews API
*
* The version of the OpenAPI document: 0.6.4
* The version of the OpenAPI document: 0.8.2
* Contact: [email protected]
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
Expand Down
2 changes: 1 addition & 1 deletion src/apis/ChatApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* AskNews API
* AskNews API
*
* The version of the OpenAPI document: 0.6.4
* The version of the OpenAPI document: 0.8.2
* Contact: [email protected]
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
Expand Down
123 changes: 123 additions & 0 deletions src/apis/ForecastApi.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
/* tslint:disable */
/* eslint-disable */
/**
* AskNews API
* AskNews API
*
* The version of the OpenAPI document: 0.8.2
* Contact: [email protected]
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/


import * as runtime from '../runtime';
import type {
ForecastResponse,
HTTPValidationError,
} from '../models/index';
import {
ForecastResponseFromJSON,
ForecastResponseToJSON,
HTTPValidationErrorFromJSON,
HTTPValidationErrorToJSON,
} from '../models/index';

export interface GetForecastRequest {
query: string;
lookback?: number;
articlesToUse?: number;
method?: GetForecastMethodEnum;
model?: GetForecastModelEnum;
cutoffDate?: string;
useReddit?: boolean;
}

/**
*
*/
export class ForecastApi extends runtime.BaseAPI {

/**
* Make an expert forecast for a news event. This endpoint reaches into the news archive, looking back `lookback` days to extract the most relevant news articles, building a timeline of events, and then making an expert forecast. This endpoint is more expensive than the search endpoint, it is calling gpt-4o or claude 3-5 on approx 15k tokens to build the forecast. This endpoint counts toward \"deep\" calls in the billing system. It returns the forecast, the reasoning, and the sources.
* Make an expert forecast for a news event.
*/
async getForecastRaw(requestParameters: GetForecastRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<ForecastResponse>> {
if (requestParameters['query'] == null) {
throw new runtime.RequiredError(
'query',
'Required parameter "query" was null or undefined when calling getForecast().'
);
}

const queryParameters: any = {};

if (requestParameters['query'] != null) {
queryParameters['query'] = requestParameters['query'];
}

if (requestParameters['lookback'] != null) {
queryParameters['lookback'] = requestParameters['lookback'];
}

if (requestParameters['articlesToUse'] != null) {
queryParameters['articles_to_use'] = requestParameters['articlesToUse'];
}

if (requestParameters['method'] != null) {
queryParameters['method'] = requestParameters['method'];
}

if (requestParameters['model'] != null) {
queryParameters['model'] = requestParameters['model'];
}

if (requestParameters['cutoffDate'] != null) {
queryParameters['cutoff_date'] = requestParameters['cutoffDate'];
}

if (requestParameters['useReddit'] != null) {
queryParameters['use_reddit'] = requestParameters['useReddit'];
}

const headerParameters: runtime.HTTPHeaders = {};

const response = await this.request({
path: `/v1/chat/forecast`,
method: 'GET',
headers: headerParameters,
query: queryParameters,
}, initOverrides);

return new runtime.JSONApiResponse(response, (jsonValue) => ForecastResponseFromJSON(jsonValue));
}

/**
* Make an expert forecast for a news event. This endpoint reaches into the news archive, looking back `lookback` days to extract the most relevant news articles, building a timeline of events, and then making an expert forecast. This endpoint is more expensive than the search endpoint, it is calling gpt-4o or claude 3-5 on approx 15k tokens to build the forecast. This endpoint counts toward \"deep\" calls in the billing system. It returns the forecast, the reasoning, and the sources.
* Make an expert forecast for a news event.
*/
async getForecast(requestParameters: GetForecastRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<ForecastResponse> {
const response = await this.getForecastRaw(requestParameters, initOverrides);
return await response.value();
}

}

/**
* @export
*/
export const GetForecastMethodEnum = {
Kw: 'kw'
} as const;
export type GetForecastMethodEnum = typeof GetForecastMethodEnum[keyof typeof GetForecastMethodEnum];
/**
* @export
*/
export const GetForecastModelEnum = {
Gpt4o: 'gpt-4o',
Claude35Sonnet20240620: 'claude-3-5-sonnet-20240620',
CommandNightly: 'command-nightly'
} as const;
export type GetForecastModelEnum = typeof GetForecastModelEnum[keyof typeof GetForecastModelEnum];
2 changes: 1 addition & 1 deletion src/apis/NewsApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* AskNews API
* AskNews API
*
* The version of the OpenAPI document: 0.6.4
* The version of the OpenAPI document: 0.8.2
* Contact: [email protected]
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
Expand Down
2 changes: 1 addition & 1 deletion src/apis/PingApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* AskNews API
* AskNews API
*
* The version of the OpenAPI document: 0.6.4
* The version of the OpenAPI document: 0.8.2
* Contact: [email protected]
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
Expand Down
162 changes: 162 additions & 0 deletions src/apis/RedditApi.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
/* tslint:disable */
/* eslint-disable */
/**
* AskNews API
* AskNews API
*
* The version of the OpenAPI document: 0.8.2
* Contact: [email protected]
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/


import * as runtime from '../runtime';
import type {
AbcAPIErrorModel29,
AbcAPIErrorModel30,
AbcAPIErrorModel31,
AbcAPIErrorModel32,
AsknewsApiErrorsAPIErrorModel,
RedditResponse,
ValidationErrorModel,
} from '../models/index';
import {
AbcAPIErrorModel29FromJSON,
AbcAPIErrorModel29ToJSON,
AbcAPIErrorModel30FromJSON,
AbcAPIErrorModel30ToJSON,
AbcAPIErrorModel31FromJSON,
AbcAPIErrorModel31ToJSON,
AbcAPIErrorModel32FromJSON,
AbcAPIErrorModel32ToJSON,
AsknewsApiErrorsAPIErrorModelFromJSON,
AsknewsApiErrorsAPIErrorModelToJSON,
RedditResponseFromJSON,
RedditResponseToJSON,
ValidationErrorModelFromJSON,
ValidationErrorModelToJSON,
} from '../models/index';

export interface SearchRedditRequest {
keywords: Array<string>;
nThreads?: number;
method?: SearchRedditMethodEnum;
deep?: boolean;
returnType?: SearchRedditReturnTypeEnum;
timeFilter?: SearchRedditTimeFilterEnum;
sort?: SearchRedditSortEnum;
}

/**
*
*/
export class RedditApi extends runtime.BaseAPI {

/**
* Go to Reddit, search threads, summarize the threads, return analysis. `deep`=True is a live web scrape, AskNews searches Reddit, finds threads, summarizes them, analyzes them, and returns the results. `deep`=False is a search in AskNews\' existing database of Reddit threads.
* Search Reddit, summarize threads, and return analysis.
*/
async searchRedditRaw(requestParameters: SearchRedditRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<RedditResponse>> {
if (requestParameters['keywords'] == null) {
throw new runtime.RequiredError(
'keywords',
'Required parameter "keywords" was null or undefined when calling searchReddit().'
);
}

const queryParameters: any = {};

if (requestParameters['keywords'] != null) {
queryParameters['keywords'] = requestParameters['keywords'];
}

if (requestParameters['nThreads'] != null) {
queryParameters['n_threads'] = requestParameters['nThreads'];
}

if (requestParameters['method'] != null) {
queryParameters['method'] = requestParameters['method'];
}

if (requestParameters['deep'] != null) {
queryParameters['deep'] = requestParameters['deep'];
}

if (requestParameters['returnType'] != null) {
queryParameters['return_type'] = requestParameters['returnType'];
}

if (requestParameters['timeFilter'] != null) {
queryParameters['time_filter'] = requestParameters['timeFilter'];
}

if (requestParameters['sort'] != null) {
queryParameters['sort'] = requestParameters['sort'];
}

const headerParameters: runtime.HTTPHeaders = {};

const response = await this.request({
path: `/v1/reddit/search`,
method: 'GET',
headers: headerParameters,
query: queryParameters,
}, initOverrides);

return new runtime.JSONApiResponse(response, (jsonValue) => RedditResponseFromJSON(jsonValue));
}

/**
* Go to Reddit, search threads, summarize the threads, return analysis. `deep`=True is a live web scrape, AskNews searches Reddit, finds threads, summarizes them, analyzes them, and returns the results. `deep`=False is a search in AskNews\' existing database of Reddit threads.
* Search Reddit, summarize threads, and return analysis.
*/
async searchReddit(requestParameters: SearchRedditRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<RedditResponse> {
const response = await this.searchRedditRaw(requestParameters, initOverrides);
return await response.value();
}

}

/**
* @export
*/
export const SearchRedditMethodEnum = {
Nl: 'nl',
Kw: 'kw'
} as const;
export type SearchRedditMethodEnum = typeof SearchRedditMethodEnum[keyof typeof SearchRedditMethodEnum];
/**
* @export
*/
export const SearchRedditReturnTypeEnum = {
Dicts: 'dicts',
String: 'string',
Both: 'both'
} as const;
export type SearchRedditReturnTypeEnum = typeof SearchRedditReturnTypeEnum[keyof typeof SearchRedditReturnTypeEnum];
/**
* @export
*/
export const SearchRedditTimeFilterEnum = {
Hour: 'hour',
Day: 'day',
Week: 'week',
Month: 'month',
Year: 'year',
All: 'all'
} as const;
export type SearchRedditTimeFilterEnum = typeof SearchRedditTimeFilterEnum[keyof typeof SearchRedditTimeFilterEnum];
/**
* @export
*/
export const SearchRedditSortEnum = {
Relevance: 'relevance',
Hot: 'hot',
Top: 'top',
New: 'new',
Comments: 'comments'
} as const;
export type SearchRedditSortEnum = typeof SearchRedditSortEnum[keyof typeof SearchRedditSortEnum];
6 changes: 4 additions & 2 deletions src/apis/StoriesApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* AskNews API
* AskNews API
*
* The version of the OpenAPI document: 0.6.4
* The version of the OpenAPI document: 0.8.2
* Contact: [email protected]
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
Expand Down Expand Up @@ -345,7 +345,9 @@ export type GetStoriesProvocativeEnum = typeof GetStoriesProvocativeEnum[keyof t
*/
export const GetStoriesStrategyEnum = {
Default: 'default',
Topstories: 'topstories'
Topstories: 'topstories',
TopstoriesCategories: 'topstories_categories',
TopstoriesContinents: 'topstories_continents'
} as const;
export type GetStoriesStrategyEnum = typeof GetStoriesStrategyEnum[keyof typeof GetStoriesStrategyEnum];
/**
Expand Down
Loading

0 comments on commit dd59117

Please sign in to comment.