Skip to content

Mobile application I prepared with ChatGPT API 💬. I have briefly specified the other parameters that you can use with this API and the usage part in the README.md file. ✍🏻

Notifications You must be signed in to change notification settings

nurllhk/ChatGPTApp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Chat GPT App

Simulator Screen Shot - iPhone 14 Pro - 2023-07-09 at 18 02 43 Simulator Screen Shot - iPhone 14 Pro - 2023-07-09 at 18 03 36

Ekran.Kaydi.2023-07-09.18.42.59.mp4

GPT API usage

  Future<String> createResponse(String newProm) async {
    const api = DefaultApi.API;
    var uri = Uri.https('api.openai.com', '/v1/completions');

    final response = await http.post(uri,
        headers: {
          'Content-Type': 'application/json',
          'Authorization': 'Bearer $api'
        },
        body: jsonEncode({
          'model': 'text-davinci-003',
          'prompt': newProm,
          'temperature': 0,
          'top_p': 1,
          'frequency_penalty': 0.0,
          'presence_penalty': 0.0
        }));

    if (response.statusCode == 200) {
      Map<String, dynamic> messageResponse = jsonDecode(response.body);
      if (messageResponse['choices'] != null &&
          messageResponse['choices'].length > 0) {
        return messageResponse['choices'][0]['text'];
      } else {
        return '';
      }
    } else {
      throw Exception(
          'Failed to create ${response.statusCode}');
    }
  }

Other parameters you can use

model
prompt
suffix
max_tokens
temperature
top_p
n
stream
logprobs
echo
stop
presence_penalty
frequency_penalty
best_of
logit_bias
user

About

Mobile application I prepared with ChatGPT API 💬. I have briefly specified the other parameters that you can use with this API and the usage part in the README.md file. ✍🏻

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published