Soulter / hugging-chat-api

HuggingChat Python API🤗
GNU Affero General Public License v3.0
817 stars 118 forks source link

Doesn't output longer response #17

Closed thisisanshgupta closed 1 year ago

thisisanshgupta commented 1 year ago

Why it does not provide long responses like I have tried "write dart code for flutter calculator app" and it exits with JSON decode error. Why so ?

RockChinQ commented 1 year ago

please provide the output

thisisanshgupta commented 1 year ago

please provide the output

Traceback (most recent call last): File "/storage/emulated/0/Download/my/hugging-chat-api/hugchat/hugchat.py", line 253, in <module> cli() File "/storage/emulated/0/Download/my/hugging-chat-api/hugchat/hugchat.py", line 240, in cli res = chatbot.chat(question) ^^^^^^^^^^^^^^^^^^^^^^ File "/storage/emulated/0/Download/my/hugging-chat-api/hugchat/hugchat.py", line 191, in chat obj = json.loads(res[1:-1]) ^^^^^^^^^^^^^^^^^^^^^ File "/data/data/com.termux/files/usr/lib/python3.11/json/__init__.py", line 346, in loads return _default_decoder.decode(s) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/data/data/com.termux/files/usr/lib/python3.11/json/decoder.py", line 337, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/data/data/com.termux/files/usr/lib/python3.11/json/decoder.py", line 355, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Same output was received on my Ubuntu machine.

kavya31-source commented 1 year ago

Facing the same issue

kokofixcomputers commented 1 year ago

I have this problem too!

RockChinQ commented 1 year ago

Please provide the prompt that you faced this problem with. Tried "write dart code for flutter calculator app", but it seems well now?

-------HuggingChat-------
Official Site: https://huggingface.co/chat
1. AI is an area of active research with known problems such as biased generation and misinformation. Do not use this application for high-stakes decisions or advice.
2. Your conversations will be shared with model authors.
Continuing to use means that you accept the above points
> write dart code for flutter calculator app
< Sure! Here's some basic Dart code that can serve as a starting point for building a simple Flutter calculator app:
```dart
import 'package:flutter/material.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Calculator',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  var _displayValue = '';

  void _incrementCounter() async {
    setState(() {
      if (_displayValue == '') {
        _displayValue = "0";
      } else {
        int value = int.parse(_displayValue);
        if (value < 9999) {
          // Increment by one
          value += 1;
          _displayValue = '$value';
        } else {
          // Reached max value, so reset to zero
          _displayValue = "0";
        }
      }
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Flutter Calculator'),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Padding(
              padding: EdgeInsets.all(8.0),
              child: Text("$ _displayValue"),
            ),
            ElevatedButton(
              onPressed: () {_incrementCounter();},
              style: ButtonStyle(textAlignment: TextAlign.center),
              child: Text(
                _displayValue.isNotEmpty ? 'Add $ _displayValue' : '',
              ),
            )
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: () {}),
      ),
      );
  }
}
RockChinQ commented 1 year ago

tried:

but never see this problem again, add invalid label now