<view class="container">
  <view class="hero">
    <view class="hero-title">营养学科普问答</view>
    <view class="hero-sub">RAG 本地知识库 + FastGPT / Dify 工作流</view>
  </view>

  <view class="card">
    <view class="card-title">问答配置</view>
    <textarea class="input textarea" data-field="question" placeholder="输入问题，如：减脂期晚餐怎么吃？" value="{{question}}" bindinput="onInput" />

    <view class="row">
      <text class="label">模型来源</text>
      <picker mode="selector" range="{{providerOptions}}" data-field="provider" bindchange="onPickerChange">
        <text class="value">{{provider}}</text>
      </picker>
    </view>

    <view class="row">
      <text class="label">问答模式</text>
      <picker mode="selector" range="{{modeOptions}}" data-field="mode" bindchange="onPickerChange">
        <text class="value">{{mode}}</text>
      </picker>
    </view>

    <view class="row">
      <text class="label">功能化建议</text>
      <picker mode="selector" range="{{adviceOptions}}" data-field="adviceType" bindchange="onPickerChange">
        <text class="value">{{adviceType}}</text>
      </picker>
    </view>

    <button class="btn btn-primary" loading="{{loading}}" bindtap="askQuestion">提问（科普问答）</button>
    <button class="btn btn-accent" loading="{{loading}}" bindtap="getAdvice">生成个性化建议</button>
  </view>

  <view class="card" wx:if="{{answer}}">
    <view class="card-title">回答结果</view>
    <view class="item-sub">{{answer}}</view>
  </view>

  <view class="card" wx:if="{{hits && hits.length}}">
    <view class="card-title">RAG 命中文档</view>
    <view class="item" wx:for="{{hits}}" wx:key="index">
      <view class="item-title">{{item.question}}</view>
      <view class="item-sub">{{item.answer}}</view>
      <view class="item-sub">score: {{item.score}} | source: {{item.source}}</view>
    </view>
  </view>
</view>
